开发者

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 ''
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜