开发者

can we escape single quote in sql server query

开发者 https://www.devze.com 2023-04-11 20:12 出处:网络
I have aproblem with the following query in SQL SERVER select ecode,ename from VW_EFORMS_Bill开发者_开发百科ingAdjustmentCodes

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

精彩评论

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

关注公众号