Catching an error from a trigger to a sp

  • Does anyone know how to catch an error from a trigger when it's rolling back to a stored procedure? Right now we have a stored procedure that keeps looping through because we can't seem to catch the error from the trigger. Can this be done? Need help. Stored procedure is too long to post to the forum. Any help would be greatly appreciated. TIA,

    Melanie

    PS. How do we catch the raiserror from the trigger?

    See sample code of what we are trying to do: Not actual code (too long to post)

    ALTER Proc TestTrig As

    Begin Tran

    --Select 'Begin Tran'

    Update Titles

    Set type = 'UndeCided'

    Where Type = 'UNDECIDED'

    commit

    --Print 'commit'

    Select @@rowcount

    Select distinct type From Titles

    ---------------------------------------------------------------------------

    ALTER TRIGGER reminder

    ON titles

    FOR INSERT, UPDATE

    AS

    RAISERROR (50009, 16, 10)

    Rollback

    return

    Select * from Master..sysmessages

  • You should be able to check the value of @@error from your stored procedure right after the insert or update statement

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

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