【问题标题】:Passing sql parameter to openquery's query [duplicate]将sql参数传递给openquery的查询[重复]
【发布时间】:2013-10-16 09:23:59
【问题描述】:

我在 SQL Server 2008 中有以下 SQL 查询

Select * from
    (Select T.Col1, T.Col2 
     from openquery('server','select * from table 1 where date= '+ @StartDate +') R

其中@StartDate 是一个参数。我收到一个错误,提示 '+' 附近的语法不正确,需要 ')'

【问题讨论】:

    标签: sql sql-server-2008 concatenation


    【解决方案1】:

    这是重复的帖子。

    简短的回答是 OPENQUERY 不接受变量作为其参数。请参阅:including parameters in OPENQUERY 了解可能的解决方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 2011-11-10
      • 2013-08-02
      • 2015-04-25
      • 1970-01-01
      相关资源
      最近更新 更多