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 |
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-05 : 07:32:52
|
Hi all,I need to update the following data in tbldefinemessagetext.textstring so any instance of 'http://m.mirror.co.uk/alerts' changes to 'http://www.telegraph.co.uk/sport/', ieAccess for 24hrs at http://m.mirror.co.uk/alerts becomes Access for 24hrs at http://www.telegraph.co.uk/sport/Cheers,Jim |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-05 : 07:38:52
|
update tableselect column = replace(column,'searchstring','newstring')where column like '%searchstring%' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-05 : 07:40:38
|
[code]declare @tbl as table(val varchar(200))insert into @tblselect 'Access for 24hrs at http://m.mirror.co.uk/alerts'union select 'Access for 24hrs at http://abc.mirror.co.uk/alerts'update @tbl set val=replace(val,'http://m.mirror.co.uk/alerts','http://www.telegraph.co.uk/sport/')from @tblselect * from @tbl[/code]PBUH |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-05 : 07:41:27
|
quote: Originally posted by webfred update tableselect column = replace(column,'searchstring','newstring')where column like '%searchstring%' No, you're never too old to Yak'n'Roll if you're too young to die.
Is there a need for the where clause?PBUH |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-05 : 09:50:52
|
quote: Originally posted by Sachin.Nand
quote: Originally posted by webfred update tableselect column = replace(column,'searchstring','newstring')where column like '%searchstring%' No, you're never too old to Yak'n'Roll if you're too young to die.
Is there a need for the where clause?PBUH
Without where clause each row will be updated. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|