SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to validate first digit in number column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

542 Posts

Posted - 07/08/2014 :  14:45:34  Show Profile  Reply with Quote
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

USA
37470 Posts

Posted - 07/08/2014 :  14:55:33  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

Sweden
30282 Posts

Posted - 07/08/2014 :  16:00:31  Show Profile  Visit SwePeso's Homepage  Reply with Quote
IF CAST(ProjNo AS CHAR(1)) = '1'




Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000