How do I stop the trigger from rolling back the entire transaction

  • Is it possible to roll the trigger back and not the whole transaction?

    eg

    insert

    trigger fails roll back trigger

    commit insert

     

    Thanks

  • I don't think it can be done... But maybe you could check for the rows that don't fit in the table and delete those (or send them to another table so that the users can see and correct the problem). That way you don't delete and reinsert valid data.

  • A trigger is an in-transaction-procedure. (has to be performed in the same transaction as the object-action it is fired from)

    This means that when your trigger fails, your whole transaction has to fail !

    Check BOL.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • You might want to try INSTEAD OF INSERT trigger on the table and handle the insert yourself.  Insert the rows you want and ignore the rows you do not want.

  • Jumping on the bandwagon here. It's an all or nothing approach and pretty useful to ensure the system's ACID properties.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

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