openrowset 为链接服务器"(null)"提供错误"OLE DB 提供程序"SQLNCLI10",返回消息"无法完成延迟的准备"。



我有一个传递给存储过程的表。现在我想在临时表#b中插入存储过程结果,使用'select * into #b from openrowset。我的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')

谁能告诉我为什么我得到错误:

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

留言8180,16层,状态1,线路1

无法准备语句。

Msg 137, 15层,2州,1线

必须声明标量变量"@t"

您必须使用执行语句声明变量@t:

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

最新更新