Replace column substring SQL Server columns

Replace all instances of FINDTHIS with REPLACEWITHTHIS in columns COLUMN1 and COLUMN2 of table TABLE where those substrings are in fact found

update TABLE set
COLUMN1=REPLACE(COLUMN1,’FINDTHIS’,’REPLACEWITHTHIS’),
COLUMN2=REPLACE(COLUMN2,’FINDTHIS’,’REPLACEWITHTHIS’)
from TABLE
where
COLUMN1 like ‘%SUBSTRINGPIECE%’ or COLUMN2 like ‘%SUBSTRINGPIECE%’

Advertisements

Posted on December 12, 2009, in Web Dev and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: