Error Handling

  • Is there a way to put a error handler in a stored procedure or trigger.

    (i.e. if i have a trigger that fails, is there a way to put in an error handler that would still commit the transaction, if something in a stored procedure fails, is there a way to put an error handler in so that the store procedure continues).

    Any info would be a big help.

    thx, scott

  • Try BEGIN TRANS and COMMIT TRANS in the trigger. I don't remember if this will work and cannot test tright now but it may.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • The trigger has an implicit transaction with the original operation. If it fails, I believe a ROLLBACK TRAN is automatically issued, which would rollback the whole transaction. As for error handlers, it depends on the severity of the error on whether or not you can trap it and do something about it. You have some control with

    SET XACT_ABORT OFF

    prior to the start of the transaction.

    K. Brian Kelley

    bkelley@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/bkelley/

    K. Brian Kelley
    @kbriankelley

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

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