all groups > sql server (alternate) > january 2004 >
You're in the

sql server (alternate)

group:

Replacing a portion of text string in column


Replacing a portion of text string in column pradip.m.sagdeo NO[at]SPAM pfizer.com
1/28/2004 7:26:03 AM
sql server (alternate):
I need to replace a portion of a url in a column as a result of
changing servers. Is there a SELECT/REPLACE/UPDATE combination query
that can do this. The table has close to a thousand entries and would
be nice if a query can be set to do this. Tried the REPLACE example
in the BOOKS ONLINE but it creates syntax error, apparently because it
does not like the characters in the url and/or wildcards. I don't need
to replace the entire url, only the portion before ".com". Thanks in
anticipation of your help.

Re: Replacing a portion of text string in column Chuck Conover
1/28/2004 9:31:26 AM
Pradip,
This statement:
select replace('http://www.technicalvideos.net','s.net','s14.net')
seems to work OK, so, perhaps you could give your exact update and the exact
error along with some sample data.
Best regards,
Chuck Conover
www.TechnicalVideos.net



[quoted text, click to view]

Re: Replacing a portion of text string in column Pradip Sagdeo
1/28/2004 5:09:01 PM
Thanks. I will try again. Must have made a typing mistake.

Pradip



*** Sent via Developersdex http://www.developersdex.com ***
Re: Replacing a portion of text string in column Erland Sommarskog
1/28/2004 11:02:53 PM
Pradip Sagdeo (pradip.m.sagdeo@pfizer.com) writes:
[quoted text, click to view]

Unfortunately, the replace() function does not support wildcards, so
if you need to use that, you have to be creative. Or descend to use
some client code to handle it.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button