SQL Escape ' '

前端 未结 7 1159
星月不相逢
星月不相逢 2021-01-12 22:49

I am trying to run a query in SQL 2008 by doing:

@query varchar(max)

SET @query = \'SELECT * FROM Table WHERE [Name] = \' \'Karl\' \' \'

EXEC(@query)
         


        
7条回答
  •  时光说笑
    2021-01-12 23:18

    Simply escape the apostrophes by using the escaping bar \ like this 'SELECT * FROM Table WHERE [Name] = ' \'Karl\' ' '

    Hope it helps

提交回复
热议问题