Triggers
A trigger is a special kind of stored procedure—one that cannot be executed explicitly. Instead, it is
attached to an event. Whenever the event takes place, the trigger fires and the trigger’s code runs.
SQL Server supports the association of triggers with two kinds of events—data manipulation events
(DML triggers) such as INSERT, and data definition events (DDL triggers) such as CREATE TABLE.
You can use triggers for many purposes, including auditing, enforcing integrity rules that cannot
be enforced with constraints, and enforcing policies.
A trigger is considered part of the transaction that includes the event that caused the trigger to
fire. Issuing a ROLLBACK TRAN command within the trigger’s code causes a rollback of all changes
that took place in the trigger, and also of all changes that took place in the transaction associated
with the trigger.
Triggers in SQL Server fire per statement and not per modified row.
www.it-ebooks.info
Do'stlaringiz bilan baham: |