How do I escape a single quote in SQL Server?

前端 未结 13 1860
情话喂你
情话喂你 2020-11-21 07:01

I\'m trying to insert some text data into a table in SQL Server 9.

The text includes a single quote(\').

How do I escape that?

13条回答
  •  长发绾君心
    2020-11-21 07:37

    This should work

    DECLARE @singleQuote CHAR 
    SET @singleQuote =  CHAR(39)
    
    insert into my_table values('hi, my name'+ @singleQuote +'s tim.')
    

提交回复
热议问题