Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping a single quote 2

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
I'm using SQL server and I want to run a simple query... well it's not so simple... but a simple version can suffice to answer my question...

Namely, I want..

INSERT INTO blah (somecolumn) VALUES ('john's boat')

I somehow need to escape that internal ', but can't figure it out... I'm fairly certain it's positive because if I just open the table and modify values I get no objections... / doesn't seem to work, nor does // or \\ or any such combo of those... nor does "john's boat"... and those are all the tricks I have up my sleeve... anyone have the answer?

-Rob
 
Hi there,

You need to add an extra single quote for each single quote that appears within the string.

i.e.,
INSERT INTO blah (somecolumn) VALUES ('john''s boat')

However, in terms of excaping the single quote in SQL Server, then is this what you are after?



Other relevant links:




Cheers,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top