Re: Triggers from one MSDE to another using DTC

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Wayne Snyder (wayne.nospam.snyder_at_mariner-usa.com)
Date: 08/06/04


Date: Fri, 6 Aug 2004 07:31:25 -0400

I agree with Mary's assessment... However to specifically answer your
question. In order to do a Distributed Transaction you must SET XACT_ABORT
ON ie see below

-- 
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jon Bishop" <JonBishop@discussions.microsoft.com> wrote in message
news:B475361A-02AE-4FD8-9AE1-0BE27A28CC89@microsoft.com...
> Hi.
>
> We are using MSDE2000 on a Point of Sale application. We need to keep a
copy
> of a few key tables as up to date as possible for backup purposes.
> We are looking at using triggers over the source tables to update the
target
> tables using a linked servers setup. Distributed Transaction Coordinator
is
> running on both source and target servers.
>
> This following  create command:
>
> CREATE TRIGGER JonsTrigger
> ON associate
> FOR INSERT
> AS
 Set Xact_abort on
> INSERT into JON1.ISR_DB.dbo.associate
> select * from inserted
   if @@error!=0
        begin
        raiserror(.....yada yada
        rollback tran
        return
        end
> GO
>
>
> will generate the following error:
>
> Server: Msg 7395, Level 16, State 2, Procedure JonsTrigger, Line 5
> Unable to start a nested transaction for OLE DB provider 'SQLOLEDB'.  A
> nested transaction was required because the XACT_ABORT option was set to
> OFF.
> [OLE/DB provider returned message: Cannot start more transactions on this
> session.]
> OLE DB error trace [OLE/DB Provider 'SQLOLEDB'
> ITransactionLocal::StartTransaction returned 0x8004d013:  ISOLEVEL=4096].
>
> OK fine, as the error says, use XACT_ABORT ON around the trigger INSERT
and
> all works well and the insert gets fired over to the target machine. I
> believe we need this set as SQL doesnt support nested transactions ? Any
way
> , so far so good . In principle it will work......
>
> The issue we have is that if the trigger fails ( target machine not
> available etc etc )  the whole transaction is rolled back including the
> originating transaction that the trigger was fired from. Problem is that
we
> dont want the original insert to fail. How can we isolate the two.
Original
> insert must occur no matter what. The trigger will do the best it can to
> update the backup DB but we dont want the whole thing to fail if it cant.
>
> I have looked around BEGIN DISTRIBUTED TRANSACTION and couldnt get it to
> make a difference. Have looked at removing the XACT_ABORT but cant get the
> update to succeed if this is missing. Have thought about using a stored
> procedure in some way but not quite sure how !
>
> Can anyone shed any light on this please.
>
> Thanks
>
> Jon
> -- 
> Software Developer
> UK


Relevant Pages

  • Re: counting rows
    ... The trigger is a simple look up via a unique index, ... isolation is that no other connections can insert rows within the key ... the row that the other transaction is insering is not visible to the ... to demonstrate what i'm talking about - current version is SQL Server ...
    (comp.databases.theory)
  • Re: SQL 7 vs. 2000 issue -trigger and nulls
    ... >We're having trouble with a trigger updating some tables. ... course be locked by the current transaction, ... locking data and updating rows when the COMMIT inside the trigger is ... I seriously hope that SQL Server 7.0 simply disregarded these two ...
    (microsoft.public.sqlserver.mseq)
  • Re: Transaction Abort in a trigger SQL 2008, writing to event log
    ... In SQL Server though, it is not handled cleanly, and you ... So if the error occured in the trigger, capture it, raise it up, ... And if you pature an error in a catch block, and do not re-raise it, it ... I always get the message that the transaction was ...
    (microsoft.public.sqlserver.programming)
  • Re: Transaction Abort in a trigger SQL 2008, writing to event log
    ... creating another transaction within the trigger. ... Links for SQL Server Books Online: ...
    (microsoft.public.sqlserver.programming)
  • Re: Trigger Deadlock
    ... RAISERROR 20000 'trg_myTable_UPDATE Update Trigger Failed. ... COMMIT TRANSACTION ... As for why you are getting deadlocks, ... SQL Server error log. ...
    (comp.databases.ms-sqlserver)