简体   繁体   中英

SQL SERVER 2008 R2 find column words in another column

I have a table looks like:

AV          AVE
AVENUE      AVE
AVEAPT      AVE
APT         #

First word to be found and replaced by second word.

I have to find these words in Address field in another table and replace all these?

What is the best way to do it?

UPDATE a
SET Address = REPLACE(Address, r.Word, r.Replacement)
FROM AddressTable AS a
JOIN ReplaceTable AS r
ON a.Address LIKE '%' + r.Word + '%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM