Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Readpast, Trigger and DTC Synergy

$
0
0

Please see my code execution flow:

  1. Delete few rows from table1 on ABC database onServer1
  2. Table1 has a After trigger on it which makes a remote server call to a proc on XYZ database on Server1.
  3. XYZ proc has a distributed transaction inside which I am running a Select statment as shown below:

 set transaction isolation level repeatable read                 
begin tran 
                declare @tasksPending int 
                set @sql = '
                                select @count_out = count(*) from ' + @Server2 + 'dbo.PQR with (READPAST) 
     where Status =1  and ActiveRecord = 1'
             
   exec sp_executesql @sql, N'@count_out int output', @count_out = @tasksPending output

Please! note that table dbo.PQR is on Server2 and in some other database.

Now My delete statement is failing with error:

Msg 1206, Level 18, State 118, Procedure XYZ, Line 65

The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

And when I am executing above steps without READPAST in the above query its working fine also outside the trigger the XYZ proc is executing fine even with READPAST. I want READPAST to be there.

Please help!


deepak




Viewing all articles
Browse latest Browse all 15889

Trending Articles