Declare @Query Var-char(100)
select @Query= 'select coalesce(NULL,"test") as testing'
Exec @Query
错误是
The name 'select coalesce(NULL,"test") as testing' is not valid identifier.
如何解决这个问题?
答案 0 :(得分:2)
1)通过键入两次来逃避查询字符串中的'(不要使用示例中的双引号) 2)执行命令后的put()
Declare @Query Varchar(100)
select @Query='select coalesce(NULL,''test'') as testing'
Exec (@Query)