Order your triggers
Credits CarbonNYC |
Ever wanted to set order on multiple triggers. You can always do so. By default they will be executed in undefined order. If you want to prioritize them then you can only do so for the first and the last trigger through the stored procedure sp_settriggerorder. It lets you set the order in which a trigger will execute. So if you have to executed multiple triggers in a predefined order then you can have max three triggers. Set order for first and last through sp_settriggerorder and the remaining one will be executed in the middle. If you have more than three then in that case the triggers except the first and last will be executed in random order. Just make sure that the same trigger name is not use to set both first and last.
Following is the example to use sp_settriggerorder: