Paste into table .. exec on linked server not working

This works by returning a result set:

exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA

When I try to insert a result set into a table:

insert into rowcount_sub (tablename,rowcnt)
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA

Failed to execute this error:

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.
+3
source share
4 answers

The operation could not be completed because the OLE DB provider "SQLNCLI10" for the linked server "svrA" could not start the distributed transaction.

The message is pretty clear and pretty explicit. All you have to do is open the system documentation and follow the steps for setting up distributed transactions: "Configuring MS DTC services" .

There are also many blogs and tutorials:

+2

, OPENQUERY EXEC:

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

, -...

+5

If you are not using a distributed transaction specifically, you can use the advanced properties of the linked server object on the main server to disable the promotion of the distributed transaction.

Disable distributed transaction promotion

+5
source

Changing "Enable distributed transaction promotion" from True to false fixed my problem.

0
source

Source: https://habr.com/ru/post/1778614/


All Articles