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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Phone Number Search

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-31 : 21:28:59
Pup writes "i have a field in a db that's a phone number. sometimes it has an area code, sometimes it doesn't. sometimes it's all squashed together like "4025558106" and sometimes it's spaced out like "402 555 8106".

i have an input box on my search page where the user will input some numbers to search by like "55810". the format of the user's input won't matter, since i'm going filter it down so that everything but the digits are stripped.

my question is this: how can i get the query to return both "402 555 8106" and "4025558106" if the search string is something like "55810"?

i can use a "LIKE" clause and get it to return if there's an exact match anywhere in the string, which would be fine for the fields without the spaces, but how do i deal with the occasional space thrown in there?

thanks."
   

- Advertisement -