SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Update command set data has apostrophe in it


Update command set data has apostrophe in it

Author
Message
lawson2305
lawson2305
SSC Veteran
SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)

Group: General Forum Members
Points: 262 Visits: 429
update [db.table] set [field]= '[BOB SAID:] "data" I want in table has multiple ' apostrophes ' in it.' where [tablefieldID] = '300'


Can someone tell me how to properly enclose this set data?
field is a ntext type
lawson2305
lawson2305
SSC Veteran
SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)

Group: General Forum Members
Points: 262 Visits: 429
searching I finally found an answer.
GilaMonster
You escape quotes by doubling them.


I find it strange when you double them it puts in the single quote. Thanks for the answer though!
Here is the corrected statement:
update [db.table] set [field]= '[BOB SAID:] "data" I want in table has multiple '' apostrophes '' in it.' where [tablefieldID] = '300'


Sean Lange
Sean Lange
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62253 Visits: 17954
lawson2305 (6/26/2013)
searching I finally found an answer.
GilaMonster
You escape quotes by doubling them.


I find it strange when you double them it puts in the single quote. Thanks for the answer though!
Here is the corrected statement:
update [db.table] set [field]= '[BOB SAID:] "data" I want in table has multiple '' apostrophes '' in it.' where [tablefieldID] = '300'



Pretty much all programming languages have certain characters you have to escape.

btw, you really should consider using nvarchar(max) instead of ntext. The text datatypes have been deprecated and they are really difficult work with.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search