[thelist] Find-and-Replace in SQL

Wade Armstrong wade_lists at runstrong.com
Fri Sep 27 12:26:01 CDT 2002


on 9/26/02 1:24 PM, Joshua Olson at joshua at waetech.com wrote:

> ----- 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


Wow, thanks, that got it exactly. I read about Replace in BOL but didn't
think it could do the job... pleasant surprise!

Wade





More information about the thelist mailing list