2010-12-05 79 views
3

這工作,返回一個結果:插入到表..高管在鏈接的服務器不工作

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

願意與MSDTC(Microsft Distributed Transaction Coordinator)服務合作嗎?您可以通過services.msc啓動它 – 2010-12-05 19:14:23

回答

5

我能夠通過使用OPENQUERY,而不是EXEC解決同樣的問題:

insert into rowcount_sub (tablename,rowcnt) 
SELECT * FROM OPENQUERY(svrA, 'select ''col'', count(1) from test.dbo.[Table1] with (nolock)') 

希望它可以幫助別人...

5

如果您沒有有意使用分佈式事務,則可以使用主服務器上鍊接服務器對象的高級屬性來禁用分佈式事務的提升。

Disable promotion of distributed transaction

0

更改「啓用分佈式事務的推廣」從真到假固定我的問題。

相關問題