Sql – Insert data from linked server stored procedure into table

linked-serversqlsql-server-2008stored-procedures

We have a setup with a SQL Server 2008 "server1" linked to another SQL server "server2".
On "server2", there is a stored procedure that I can query just fine from "server1":

EXEC [server2].[xx].[dbo].[sp] param

However, as soon as I start inserting data from the linked server SP, we run into problems.
We use the following code:

INSERT INTO server1.dbo.table (column1, column2, ...)
EXEC [server2].[xx].[dbo].[sp] param

When we started out, we received the "known" errors like:

OLE DB provider "SQLNCLI" for linked server "linkedserver" returned message "The partner transaction manager has disabled its support for remote/network transactions.". Msg 7391, Level 16, State 2, Line 2 The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "linkedserver" was unable to begin a distributed transaction.

As stated in similar questions like:
inserting to a local table from a linked stored procedure
Inserting Results Of Stored Procedure From Linked Server

So, we configured MSDTC on both servers. Now the query runs for 20 seconds and then aborts with the error message:

OLE DB provider "SQLNCLI10" for linked server "server2" returned message "No transaction is active.".
Msg 7391, Level 16, State 2, Line 14
The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "server2" was unable to begin a distributed transaction.

As opposed to the previous errors, there is nothing in the Windows Event log.

First of all, is my query considered as a distributed transaction because of the INSERT into a local table?

Second, if I try to execute a distributed query like this:

begin distributed tran
select * from [server2].master.sys.sysprocesses
commit tran

I get the exact same error message after exactly 20 seconds.

I don't know how to investigate further from here. Could it be a firewall issue?

Best Answer

If you don't need distributed transactions, the solution at @rs's link above worked for me. Repeating the solution here:

EXECUTE sp_serveroption @server = '<remote_linked_server_name>', @optname = 'remote proc transaction promotion', @optvalue = 'false';

This tells the sql server instance to not promote transactions to the linked server. Be aware this may have other consequences so use with discretion.