Preserving Trace/Logging Data during a transaction rollback?

  • Is there a way to rollback a tranaction still preserve data logged to tables within it, or a am i barking up the wrong tree? I

    For example:

    begin try

    begin tran

    exec proc1

    exec logger msg = 'proc1 said hello world!'

    exec proc2

    exec logger msg = 'proc1 said houston, we have a problem'

    end try

    catch

    get exception data

    end catch

    ....

    if bad rollback tran

    else commit

    After rollback of course, all log messages are gone.

    Thanks,

    Scott

  • If you log your messages to a table variable first, you can then write those messages to a permanent table outside of teh transaction (either after the commit or rollback). Table variables are not affected by transactions.

  • True, I like that idea.

    The only catch is I've already standardized and coded the logging procs, and interspersed them in the code. I was hoping there was something easy where I wouldn't to recode to much but I supposed that would go against the whole idea of the transaction. I'll give your idea a shot.

    Thanks,

    Scott

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

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