3

I have two linked servers and want to create a stored procedure that simply SELECTs data from one table from the first server and INSERT the data in other table from the second server.

The procedure code looks like this:

BEGIN TRAN
INSERT INTO [RI].[TEST_DB].[TEST_TABLE] (...)
SELECT ...
FROM [TABLE]
TRUNCATE [TABLE]
COMMIT TRAN

But I get the following error:

OLE DB provider "SQLNCLI11" for linked server "RI" returned message "Cannot start more transactions on this session.".
Msg 7395, Level 16, State 2, Procedure usp_test, Line 46
Unable to start a nested transaction for OLE DB provider "SQLNCLI11" for linked server "RI".
A nested transaction was required because the XACT_ABORT option was set to OFF.

marc_s
9,0626 gold badges46 silver badges52 bronze badges
asked Feb 2, 2015 at 9:36

1 Answer 1

6

As the error message suggests, add the following to your stored procedure:

SET XACT_ABORT ON;

See Distributed Queries and Distributed Transactions

answered Apr 16, 2016 at 12:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.