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
 Quote and single quote in sql function

Author  Topic 

nikl
Starting Member

7 Posts

Posted - 2013-01-09 : 11:03:06
Hi!

I am trying to replace a couple of quotes with single quotes in my database. The values I am trying to replace are all in the form of "xyz", so the code I am trying to run looks as following:
UPDATE catalog SET description = replace(description,""xyz"","'xyz'");


However this will throw an error and I would therefore like to know how to batch replace every "xyz" with 'xyz'.

Thanks in advance!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2013-01-09 : 11:19:39
UPDATE catalog SET description = replace(description,'"xyz"','''xyz''');




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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-09 : 22:26:22
see

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nikl
Starting Member

7 Posts

Posted - 2013-01-10 : 04:55:19
Thanks both of you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-10 : 04:58:35
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -