【问题标题】:Issue with coalesce in T-SQLT-SQL 中的合并问题
【发布时间】:2013-10-15 01:07:15
【问题描述】:
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.

如何解决这个问题?

【问题讨论】:

    标签: sql-server tsql coalesce


    【解决方案1】:

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

    Declare @Query Varchar(100)
    select @Query='select coalesce(NULL,''test'') as testing'
    Exec (@Query)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      相关资源
      最近更新 更多