0
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.

如何解决这个问题?

4

1 回答 1

2

1)通过键入两次来转义查询字符串中的'(不要像您的示例中那样使用双引号)2)在exec命令之后放置()

Declare @Query Varchar(100)
select @Query='select coalesce(NULL,''test'') as testing'
Exec (@Query)
于 2013-10-08T08:08:55.163 回答