--A服务器存储过程
CREATE procedure sp_test
as
begin
SET NOCOUNT ON
declare @s varchar(max)='
create table #A
(
a int
)
insert into #A values(1)
select a from #A
drop table #A
'
exec(@s)
end
--B服务器调用
create table #AA
(
a int
)
insert into #AA
EXEC [服务器].数据库.dbo.sp_test
--SQL提示:错误消息 OLE DB 提供程序 SQLOLEDB 无法启动分布式事务
--如下调用,可以解决(SQL2012+)
insert into #AA
exec(
'select * from openquery
(
服务器,''exec 数据库.dbo.sp_test
WITH RESULT SETS
(
(
b int
)
)
''
)'
)
1674

被折叠的 条评论
为什么被折叠?



