Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select only 10 or 11 digit numbers

Author  Topic 

spowell
Starting Member

23 Posts

Posted - 2010-07-28 : 19:12:51
I have a table which has got a lot of phonenumbers in. The problem I have is that it also has a lot of incorrect phonenumbers as well. All the phone numbers I want from the table are either 10 or 11 digits long so is there a select query that would just return the rows that had either a 10 or 11 digit number in them?

eg

01225111222
016771112221
01123123
0456111222

would return results of

01225111222
0456111222

Thanks for reading

singularity
Posting Yak Master

153 Posts

Posted - 2010-07-28 : 20:21:00
select phone
from yourtable
where len(phone) between 10 and 11
Go to Top of Page

spowell
Starting Member

23 Posts

Posted - 2010-07-29 : 04:53:45
Thanks a lot for your help
Go to Top of Page
   

- Advertisement -