Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mlmeyer
Starting Member
26 Posts |
Posted - 2005-05-16 : 16:47:06
|
| Quick question on updating fields in a table. I just need to update all the URLs in a SQL database field so they include a new folder root. So, for example, I need to change this URLhttp://www.website.com/images/image1.gifto http://www.website.com/images/home/images1.gifIn other words I just need to add the /home directory to all of the URLs in an image field of a table without changing anything else. I am sure there is an easy way to do this but I can't seem to find it. |
|
|
CactusJuice
Starting Member
46 Posts |
Posted - 2005-05-16 : 23:20:30
|
| [code]SELECT STUFF('http://www.website.com/images/image1.gif', 30, 0, 'home')[/code]Note, this is a very simplified example (I used fixed 30 for start location). Use PATINDEX or CHARINDEX to get this.Check out BOL for the string functions. |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-05-17 : 01:43:53
|
Or you could use REPLACESELECT REPLACE('http://www.website.com/images/image1.gif','/images/','/images/home/')AndyBeauty is in the eyes of the beerholder |
 |
|
|
|
|
|