[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2007-12-04
5
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 143

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

650 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