Solved

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

Posted on 2007-12-04
5
333 Views
Last Modified: 2012-08-13
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
Comment
Question by:Endelm
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20401990
>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
 

Author Comment

by:Endelm
ID: 20401996
Sorry the data type was bigint.
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20402004
Then that is the best way to do. No other better options
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20402014
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
 

Author Comment

by:Endelm
ID: 20402020
Thank you! :-)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now