Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write a string search and replace SQL statement? 1

Status
Not open for further replies.

texnut

IS-IT--Management
Jan 11, 2007
97
US
Hello all,

I have a database table that has about 400 or so URLs in it.

I have to change part of the string that makes up the URL.

Here is an existing URL string:
file://server1/share/file

I need to change this to:
file://server2/share/file

Anyone know how I can do this quickly using an SQL statement?

Thanks for any help on this!
 
Code:
Select Replace(URL, 'file://Server1/', 'file://Server2/') As NewURL
From   YourTable

If you need to do this permanently, and the above query returns the correct data, then you can update the table like this:

Code:
Update TableName
Set    URL = Replace(URL, 'file://Server1/', 'file://Server2/')



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
gmmastros, thank you - it worked perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top