Solved

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

Posted on 2007-12-04
5
338 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 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

730 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