[thelist] Find-and-Replace in SQL

Joshua Olson joshua at waetech.com
Thu Sep 26 15:26:01 CDT 2002


----- Original Message -----
To: <thelist at lists.evolt.org>
Sent: Thursday, September 26, 2002 4:18 PM


> The problem is, each page's copy is stored in a table that looks like
this:
> pageid int identity(1,1)
> pagetitle varchar(255)
> pagecopy varchar(8000)
>
> The "Old Company Name" needs to be replaced with "New Company Name" in
> pagecopy, a varchar field holding all of the page's copy, without
disturbing
> the rest of the copy.
>
> Thanks again. I clearly need lots more coffee today!

How about:

UPDATE companypage
SET pagetitle = Replace(pagetitle, 'Old Company Name', 'New Company Name')
  , pagecopy = Replace(pagecopy, 'Old Company Name', 'New Company Name')

This should work on SQL Server.

-joshua




More information about the thelist mailing list