The purpose of a trigger is to extend the statement that fired the trigger. Typically, there are three types of actions:
1) Integrity checks that cannot be done with constraints.
2) Cascading updates.
3) Auditing (which can be seen as a case of cascading updates).
The key is that without the trigger the statement is not whole. Specifically, if any of the statements in the trigger fail, the action that fired the trigger has also failed.
So this is the first thing you need to ask yourself: if the attempt to send a mail or SMS fails, should that rollback the statement that fired the trigger. If the answer is yes, a trigger is exactly what you need. But if the answer is no, you are barking up the wrong tree.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
No comments:
Post a Comment