Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trigger insert into a linked server

Status
Not open for further replies.

shabata

Programmer
May 27, 2004
2
FR
Hi guys!
This is my first thread on tek-tips.com, and I'm from France...excuse my english.
I work with two linked servers (say A and B). From a table T1 of A I have set up a trigger insert which launch an insert on a table T2 of B. But it doesn't work.
Error is
Code:
ole/db provider returned message:cannot start more transactions on this session
However, I wrote the same insert into a store procedure and when I execute it, it works fine.
I don't understand where the problem is.
thanks for any help
Bert.
 
I've got the answer!!!
Here it is :
I marked the option : "Apply distributed transactions" in "Connexions" in the properties of both servers in Entreprise Manager.
Then I addes "SET XACT_ABORT ON" at the beginning of my trigger
my trigger :
Code:
CREATE TRIGGER [triggeressai] ON [BERTRAND].[AFFAIRE_ACTION]
FOR INSERT
AS
BEGIN
DECLARE
@nor varchar(15), @noaff varchar(15), @date datetime, @montant numeric, @marge numeric
SET XACT_ABORT ON
SET @nor=(SELECT NOR FROM Inserted)
SET @noaff=(SELECT NAFF FROM Inserted)
SET @date=(SELECT DATE_ACTION FROM Inserted)
SET @montant=(SELECT MONTANT FROM Inserted)
SET @marge=(SELECT MARGE FROM Inserted)
INSERT INTO [SERVEURWEB].[DEMO_GESTION].[dbo].[AFFAIRE_ACTION]
VALUES(@nor,@noaff,'BC',@date,@montant,@marge)
SET XACT_ABORT OFF
END

IT WORKS FINE !!! That's awesome...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top