How to prevent Insert query from being included in a distributed transaction?

I have a SQL Insert query inside a stored proc, to insert rows into a linked server table .

Because the stored procedure receives a call in the parent transaction, this Insert statement attempts to use DTC to insert rows into the linked server.

I would like to avoid DTC.

Is there a way to do this (as a hint) for an Insert SQL statement to ignore the transaction scope?

+3
source share
2 answers

, , , , - . , , , SProc.

, .NET 2.0 System.Transaction, . , , .

.

, .

+4

openquery /sp

... * from mylinkedserver.pubs.dbo.authors

. DECLARE @TSQL varchar (8000), @VAR char (2) SELECT @VAR = 'CA' SELECT @TSQL = 'SELECT * FROM OPENQUERY (MyLinkedServer,' 'SELECT * FROM pubs.dbo.authors WHERE state =' '' '' '+ @VAR +' '' '' '') '

.....     EXEC (@TSQL)

0

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


All Articles