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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search string with single quotation mark?

Status
Not open for further replies.

takyan

Programmer
Oct 16, 2002
84
HK
Hi,

If the string contains single quotation mark, how can I search it using SQL??

E.g. the string is "o'clock",
select * from table1 where code = 'o'clock'

Please advise.

Yan
 
Two ways I know, replace the single quote with 2 single quotes

select * from table1 where code = 'o''clock'

or

set quoted_identifier off
select * from table1 where code = "o'clock"

Have a look in BOL - Delimited Identifiers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top