Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to validate first digit in number column

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2014-07-08 : 14:45:34
I have number column projNo, how to validate the first digit of projno

if (projno,1,1) =1 then
begin
---Apply this logic

end
else
begin
---Apply diff logic
end

Thanks a lot for the helpful info

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-08 : 14:55:33
Not sure if there's a math way to do it, but here you go:

if left(convert(varchar(20), @i), 1) = '1'

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-07-08 : 16:00:31
IF CAST(ProjNo AS CHAR(1)) = '1'




Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -