Sql-server – How triggers are called when we have two triggers

sql servertrigger

In a table I have two triggers. When it is called for the first time the first trigger does not fires while the second trigger's got fired. On the next call both first and second trigger action take place. So in my case when calling the trigger first time the first trigger should be executed then the second one. Any suggestions?

Best Answer

If I am understanding your question correctly, you are looking for the sp_settriggerorder system stored procedure (http://msdn.microsoft.com/en-us/library/ms186762.aspx). Through the used of this stored proc you can set whether a trigger fires first or last (or undefined, and any trigger in between first and last has no guaranteed order).

(Note: this only applies to AFTER triggers, and cannot be used with INSTEAD OF triggers)