这样可以返回结果集:
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
当我尝试将结果集插入表中时:
insert into rowcount_sub (tablename,rowcnt)
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
未能发出此错误:
OLE DB provider "SQLNCLI10" for linked server "svrA" returned message "No transaction is active.".
Msg 7391, Level 16, State 2, Line 1
The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "svrA" was unable to begin a distributed transaction.
答案 0 :(得分:5)
我能够通过使用OPENQUERY而不是EXEC来解决同样的问题:
insert into rowcount_sub (tablename,rowcnt)
SELECT * FROM OPENQUERY(svrA, 'select ''col'', count(1) from test.dbo.[Table1] with (nolock)')
希望它有所帮助...
答案 1 :(得分:5)
答案 2 :(得分:2)
无法执行操作 因为OLE DB提供程序“SQLNCLI10” 对于链接服务器“svrA”无法 开始分布式交易。
该消息非常明确且非常明确。您所要做的就是打开系统文档并按照配置分布式事务的步骤进行操作:Configuring MS DTC Services。
还有很多博客和教程:
答案 3 :(得分:0)
将“启用分布式事务的促销”从True更改为false修复了我的问题。