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.
| Author |
Topic |
|
rme8494
Yak Posting Veteran
98 Posts |
Posted - 2005-03-03 : 15:30:34
|
| Is there a better way to do this like search?WHERE REPLACE(REPLACE(CustomerName,'.',''),',','') LIKE REPLACE(REPLACE(@SearchString,'.',''),',','')Basically what I'm trying to do is respond to a user request where we have customers in our database that could be named US Govt, or U.S. Govt. So I was asked to take periods, commas and dashes out of both sides of the search. What I've come up with so far is what I have above. It doesn't look that nice, is there a better way?Thanks,RyanRyan EverhartSBCSBC. Going Beyond the Call! |
|
|
trivialusername
Starting Member
6 Posts |
Posted - 2005-03-03 : 15:41:58
|
| Have you tried soundex?wheresoundex(customername) = soundex(@searchstring)This is a really useful text matching function.Rob |
 |
|
|
rme8494
Yak Posting Veteran
98 Posts |
Posted - 2005-03-03 : 15:56:16
|
| trivial,That didn't have the result I was looking for...ExampleDECLARE @cn VARCHAR(50)SET @cn = 'AF ASSOCIATES INC'SELECT *FROM TECustomerWHERE SOUNDEX(CustomerName) LIKE SOUNDEX(@cn)Should return: A.F. ASSOCIATES INCInstead it returned:AVAYA FINANCIAL SERVICESAUB FAITH COM HOSP INCABBA WOMENS CENTERABBY EXEC SVCSAHEPA 29 INCAHEPAAHEPA INC.AHF WINDSOR INC C/O KETTLEBROOK HEALTH CAAVAYA COMMUNICATION AVP INC AVE MARIA PRESSRyan EverhartSBCSBC. Going Beyond the Call! |
 |
|
|
trivialusername
Starting Member
6 Posts |
Posted - 2005-03-03 : 17:01:47
|
| You're right. Sorry about that. Looks like soundex has issues with multiple word strings. Will store that in the 'ole memory bank for future reference. |
 |
|
|
|
|
|
|
|