Re: Trigger problem (losing my mind here!)
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 02/10/05
- Next message: Tibor Karaszi: "Re: Client side printing"
- Previous message: Aaron Weiker: "Re: Downloading File located in SQL Server with ASP"
- In reply to: Fat Superman: "Trigger problem (losing my mind here!)"
- Next in thread: Fat Superman: "Re: Trigger problem (losing my mind here!)"
- Reply: Fat Superman: "Re: Trigger problem (losing my mind here!)"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Feb 2005 15:32:10 +0100
The difference is that for the single INSERT, the remote insert is the only operation in the
transaction. For the trigger case, the remote insert is in the same transaction as the insert on the
STK_MOVEMENTS table. This makes it a distributed transaction, so DTC need to be in place.
Also, why are you INSERTing into OPENQUERY? Why not just use 4-part naming and specify the qualifies
table name, just as a regular INSERT?
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ http://www.sqlug.se/ "Fat Superman" <FatSuperman@gmail.com> wrote in message news:1108042691.241861.256170@f14g2000cwb.googlegroups.com... > Hi everyone > > I have something interesting (annoying) going on with my trigger on > SQL2K, I've noticed several threads on this in the past, but no > resolution for the posters. > > I have a simple insert statement which puts a few fields into a table > on a linked server. > > Code that works in SQL QA: > INSERT OPENQUERY(DBODBC, 'SELECT * FROM STOCK') values ('StockCode', > 111, 'Reference') > This code works fine from SQL query analyzer but fails when run as a > trigger. > > Code that FAILS in SQL trigger > CREATE TRIGGER HN_TRAN_STKMOVE > ON STK_MOVEMENTS > AFTER INSERT AS > INSERT OPENQUERY(DBODBC, 'SELECT * FROM STOCK') values ('StockCode', > 111, 'Reference') > > The error I get is "The operation could not be performed because the > OLE DB provider 'MSDASQL' was unable to begin a distributed > transaction" - I don't understand the difference between running the > code from QA and using it on a trigger!!? > > Anybody got any ideas? > Thanks as always! > David >
- Next message: Tibor Karaszi: "Re: Client side printing"
- Previous message: Aaron Weiker: "Re: Downloading File located in SQL Server with ASP"
- In reply to: Fat Superman: "Trigger problem (losing my mind here!)"
- Next in thread: Fat Superman: "Re: Trigger problem (losing my mind here!)"
- Reply: Fat Superman: "Re: Trigger problem (losing my mind here!)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|