Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Update command set data has apostrophe in it Expand / Collapse
Author
Message
Posted Wednesday, June 26, 2013 12:21 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Yesterday @ 7:18 AM
Points: 69, Visits: 350
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
Post #1467807
Posted Wednesday, June 26, 2013 12:36 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Yesterday @ 7:18 AM
Points: 69, Visits: 350
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'

Post #1467813
Posted Wednesday, June 26, 2013 1:05 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:04 PM
Points: 13,086, Visits: 12,553
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 Moden's 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)
Post #1467823
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse