Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I would like a query to match the following:"521 S Cedar St" and "521 S. Cedar St."That is, I want to ignore punctuation like period and comma.I don't think LIKE can do this, but would something like this?SELECT * WHERE REPLACE(REPLACE(Addr1,'.',''),','.'')=@Addr1Assuming @Addr1 had no punctuation?What about repeated spaces? Does SQL match "521bbCedar' and '521bCedar"?kpg
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-08-15 : 10:26:02
You could perhaps do
SELECT * FROM YourTable WHERE REPLACE(REPLACE(REPLACE(Addr1,',',''),'.',''),' ','') = REPLACE(REPLACE(REPLACE(@Addr1,',',''),'.',''),' ','')
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-08-15 : 10:29:37
yep..you can use another replace() to strip off the spacesREPLACE(REPLACE(REPLACE(Addr1,'.',''),','.''),' '),'')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/