Linked server can't start distributed transaction in trigger

6.8k views Asked by At

I have a trigger that calls a stored proc. In the stored proc there's an INSERT statement on a Linked Server that gives me:

The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "MyServer" was unable to begin a distributed transaction.

But when I replace the variable values in the sql string with the actual values and I run the exact same statement manually (i.e. not via the Trigger), it inserts the record.

DTC is enabled. Is my DTC settings wrong?

Query being executed:

INSERT INTO [MyServer].WorkForce.dbo.Faults (FaultID, CreatedOn, FaultStart, Reason, Description,  TaskID)
SELECT @NewFaultID, GETDATE(), T.CreatedOn, ISNULL(I.Reason, 'Unknown'), WFR.Description,
       T.TaskID
FROM Inserted I 
     INNER JOIN Tasks T ON I.TaskID = T.TaskID
     INNER JOIN FaultReasons WFR ON I.Reason = WFR.Reason
WHERE T.TaskID = I.TaskID

I'm using SQL Server 2012

2

There are 2 answers

1
Cameron Castillo On BEST ANSWER

I posted too quickly and found the answer, and yes the DTC settings were wrong. I enabled 'Allow Inbound', 'Allow Outbound' and 'No Authentication Required' and now it works.

0
Hiram On

--fixed by : EXEC master.dbo.sp_serveroption @server=N'SVRLINK', @optname=N'remote proc transaction promotion', @optvalue=N'false'