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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 find and replace

Author  Topic 

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-07-29 : 16:07:18
Does anyone know the syntax to select varchar data from a field, search the varchar data for a specific string, and replace the string with something else?

I'm trying to search for L2 in L2109got and change it to L3.

Please help. Thanks,

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-29 : 16:19:34
UPDATE Table1
SET Col1 = REPLACE(Col1, 'L3', 'L2')
WHERE Col1 LIKE '%L2%'



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-07-29 : 16:20:11
Do you have Books On Line. Read about REPLACE statement.

Go to Top of Page

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-07-29 : 16:30:30
Thank you so much, this worked great!
Go to Top of Page
   

- Advertisement -