SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Quote and single quote in sql function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nikl
Starting Member

Germany
7 Posts

Posted - 01/09/2013 :  11:03:06  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 01/09/2013 :  11:19:39  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

India
52325 Posts

Posted - 01/09/2013 :  22:26:22  Show Profile  Reply with Quote
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

Germany
7 Posts

Posted - 01/10/2013 :  04:55:19  Show Profile  Reply with Quote
Thanks both of you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 01/10/2013 :  04:58:35  Show Profile  Reply with Quote
welcome

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000