Tuesday, July 3, 2007

Trigger Order

How can I guarantee the order that SQL Server fires triggers?

 

 

   SQL Server 7.0 does not guarantee the firing order of multiple triggers for the same action.  If you need things to happen in a particular order, you'll need to put all the code in a single trigger.

 

In SQL 7.0 triggers actually fire in object id order, but this is NOT documented or guaranteed and therefore could change without warning in a service pack or new version.

 

With SQL 2000 you can now define the first and last trigger to fire using sp_settriggerorder. This is only available for AFTER triggers.

No comments: