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!

single quote mark in Dyanamic sql string

Status
Not open for further replies.

spaliwal

Programmer
Dec 28, 2001
31
IN
Hi

For migration purpose i am building sql string dyanmically by the dbf data , making some translation and finally moving it into sql server 2000, many of the places old data contains single quote mark as given below

SELECT OID FROM InsurancePlanHeader WHERE PlanCode = 'PHYSICIAN'S MUTUAL' AND DELETEOID = '0'

Here 'PHYSICIAN'S MUTUAL' produces error message

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'S'.
Server: Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark before the character string ''.

since this string formed dyanmically by the data , i am not able to control this situation.Pl. suggest how ot handle this situation.
 
You need to use double quotes around your where clause

SELECT OID FROM InsurancePlanHeader WHERE PlanCode = "PHYSICIAN'S MUTUAL" AND DELETEOID = '0'

Rick.
 
You need to add only one quote before S as below

SELECT OID FROM InsurancePlanHeader WHERE PlanCode = 'PHYSICIAN''S MUTUAL' AND DELETEOID = '0'



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top