MSSQL 2005 - Check if an integer is longer than 12 letters

Hi,

If I have a int column that I wanna check if is longer than 12 letters, is there any better way of doing it rather than something like this:

select *
from myTable
where mycolumn > 999999999999

Thank you.
EndelmAsked:
Who is Participating?
 
imitchieConnect With a Mentor Commented:
That's probably the best way. But depending on how Bigints are stored internally, probably worth trying

select * from myTable
where len(cast(mycolumn as varchar)) > 12
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>is there any better way of doing it rather than something like this:
isn't that good "enough" ?

now, int cannot be that big, the range for int is:
-2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)

so max 10 digits...
0
 
EndelmAuthor Commented:
Sorry the data type was bigint.
0
 
Ashish PatelCommented:
Then that is the best way to do. No other better options
0
 
EndelmAuthor Commented:
Thank you! :-)
0
All Courses

From novice to tech pro — start learning today.