【问题标题】:openrowset is giving error "OLE DB provider "SQLNCLI10" for linked server "(null)" returned message "Deferred prepare could not be completed."openrowset 为链接服务器“(null)”返回错误“OLE DB 提供程序“SQLNCLI10”返回消息“无法完成延迟准备”。
【发布时间】:2015-07-26 11:01:49
【问题描述】:

我有一个表被传递到存储过程中。现在我想使用'select * into #b from openrowset 将存储过程结果插入临时表#b。我的sql代码如下:

create type add1 as table
(score int)

alter proc qwe123
@table add1 readonly
as
begin
select score,score + 2 as cal
from @table
end

go

declare @t add1 
insert into @t
select score
from abc

select * into #b from
openrowset('sqlncli','server=localhost;trusted_connection=yes','exec qwe123 @t')

谁能告诉我为什么会出现错误:

链接服务器“(null)”的 OLE DB 提供程序“SQLNCLI10”返回消息“延迟准备无法完成。”。

消息 8180,第 16 级,状态 1,第 1 行

无法准备声明。

消息 137,第 15 级,状态 2,第 1 行

必须声明标量变量“@t”。

【问题讨论】:

    标签: sql-server-2008


    【解决方案1】:

    你必须用执行语句声明你的变量@t

    openrowset('sqlncli','server=localhost;trusted_connection=yes',
        'DECLARE @t add1 = 1 exec qwe123 @t')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      • 2018-03-17
      • 2013-03-28
      • 2011-09-18
      相关资源
      最近更新 更多