I have a table called MyTable
on which I have defined a trigger, like so:
CREATE TRIGGER dbo.trg_Ins_MyTable
ON dbo.MyTable
FOR INSERT
AS
BEGIN
SET NOCOUNT ON;
insert SomeLinkedSrv.Catalog.dbo.OtherTable
(MyTableId, IsProcessing, ModifiedOn)
values (-1, 0, GETUTCDATE())
END
GO
Whenever I try to insert a row in MyTable
, I get this error message:
Msg 3910, Level 16, State 2, Line 1 Transaction context in use by another session.
I have SomeLinkedSrv
properly defined as a linked server (for example, select * from SomeLinkedSrv.Catalog.dbo.OtherTable
works just fine).
How can I avoid the error and successfully insert record+execute the trigger?
OtherTable
has no triggers defined – Boisvertinstead of
fails with the same error. 2. No (explicit) transaction; just a plaininsert MyTable (<fields>) values (<values>)
. 3. Yes, that will surely do it, but it involves some work. I was wondering if it's possible to solve this directly in TSQL. – Boisvert