Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Null or Blank Phone Numbers In SQL

Status
Not open for further replies.

vcujackson

Technical User
Apr 7, 2009
18
US
SELECT addrid, addrphone, addrline1, addrcity, addrplace, addrzipcod, addrdate
FROM dbo.address_full
WHERE
(addrphone NOT LIKE '[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9][0-9]')
AND (addrforign = 'N')
and addrphone is not null

Platform used: SQL 2005
The above script is supposed to pull all invalid phone numbers or those that do not follow the following pattern:
XXX.XXX.XXXX
When I run this in QA, I do get the invlaid numbers but I also get blank or null values in the phone field even though I put in a statement at the end that says and addrphone is not null. Why am I getting the blank or null phone numbers?
 
change:

and addrphone is not null

To:

and addrphone > ''

This will remove null's and rows that are empty string.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top