Escape Character in SQL Server

前端 未结 9 1413
时光取名叫无心
时光取名叫无心 2020-11-29 03:22

I want to use quotation with escape character. How can I do?

I have received error in SQL Server

Unclosed quotation mark after the character strin

9条回答
  •  粉色の甜心
    2020-11-29 03:45

    If you want to escape user input in a variable you can do like below within SQL

      Set @userinput = replace(@userinput,'''','''''')
    

    The @userinput will be now escaped with an extra single quote for every occurance of a quote

提交回复
热议问题