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)
 update sql with multiple '''

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2011-07-01 : 02:58:36
I have data that because of a mistake one ' went in as many

how can I do a update statement to replace all duplicate ''''' (single quotes) with one single quote.

is there an easy update statement that I can do

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-07-01 : 03:04:08
Test this:

update table
set column=select replace(replace(replace(column,'''','~#'''),'''~#',''),'~#','')
where column like '%''''%'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-01 : 03:36:27
WHILE EXISTS (SELECT * FROM dbo.Table WHERE Col1 LIKE '%' + CHAR(39) + CHAR(39) + '%')
UPDATE dbo.Table1 SET Col1 = REPLACE(Col1, CHAR(39) + CHAR(39), CHAR(39))


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

- Advertisement -