[thelist] Find-and-Replace in SQL

Wade Armstrong wade_lists at runstrong.com
Thu Sep 26 15:19:02 CDT 2002

on 9/26/02 1:06 PM, Carlos Costa Portela at ccosta at servidores.net wrote:

> On Thu, 26 Sep 2002, Wade Armstrong wrote:
>> I have a client who has changed their company's name. Many moons ago, we
>> built these folks a Web site with a content management system using SQL
>> Server 7.0 and ASP. Their site has grown to a couple hundred pages, and I'd
>> love to be able to just put in some SQL command like "REPLACE 'Old Company
>> Name' WITH 'New Company Name' IN table_name" but sadly it seems that REPLACE
>> doesn't work that way. Is there a way to do this in straight SQL?
> Try with
> UPDATE table_name SET name='New Company Name' where name='Old
> Company Name' ;
> Is there a lot of tuples with 'Old Company Name' ?
> Hope this helps,
> Carlos.

It would if I had made myself clear.

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!


More information about the thelist mailing list