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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Find and Replace values

Author  Topic 

twynsys
Starting Member

2 Posts

Posted - 2007-12-07 : 10:56:13
I was wondering how to do a find and replace with SQL? Would I use a SET statement?

I need to find a specific value and replace all of the results with a different value.

Thanks for all responses.

nr
SQLTeam MVY

12543 Posts

Posted - 2007-12-07 : 11:01:20
update tbl
set fld = @newval
where fld = @oldval

update tbl
set fld = replace(fld, @oldchars, @newchars)
where fld like '%' + @oldchars + '%'

select @str = replace(@str, @oldchars, @newchars)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -