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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

567 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
38200 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
30421 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  
 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.08 seconds. Powered By: Snitz Forums 2000