[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

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.
0
Endelm
Asked:
Endelm
1 Solution
 
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
 
imitchieCommented:
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
 
EndelmAuthor Commented:
Thank you! :-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now