Exclude part of the code in a transaction

  • Hello,

    I have a TSQL code inside a Transaction,

    I would like to exclude a piece of that code from the transaction (I do need to recovere it in the trasaction log).

    For instance

    BEGIN TRAN

    SQL Statement 1

    SQL Statement 2 -- out of the transaction

    SQL Statement 3

    COMMIT TRAN

    I would like to exlude SQL Statement 2 (SQL statement1 and 3 must be inside the same transaction)

    Is it possible? How to do it?

    Thank

  • Do you need the results of Statement 2 for statement 3? If it is not important that statement 2 executes successfully (since you want it to be outside the transaction) I assume this is the case. So you could write the necessary information that is needed for Statement 2 into a queue and process it in a different transaction. You can do this either by a polling a queue table, or, in a more efficient way, by using the Service Broker in 2005 (in which case the queue will be a SQL Server queue object (see http://msdn2.microsoft.com/en-us/library/ms190495.aspx, and putting something on this queue is a "begin dialog;send" statement sequence.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply