can we escape single quote in sql server query
I have a problem with the following query in SQL SERVER
select ecode,ename
from VW_EFORMS_Bill开发者_开发百科ingAdjustmentCodes
where ename='Ravi's friend';
In the Above Query "Ravi's Friend" is a string from DB. can i escape the single quote please help me..
You can use two quotes:
'Ravi''s friend'
Or use a parameterized query and supply the string as a parameter:
SELECT ecode, ename
FROM VW_EFORMS_BillingAdjustmentCodes
WHERE ename = ?
A single quote in a string is escaped by two single quotes in a row (''
).
where ename='Ravi''s friend'
^^ two ''
精彩评论