Trigger Utilization


Triggers are like stored procedures in that they contain a set of T-SQL statements saved for future execution. The big difference is that, unlike stored procedures, triggers are executed automatically based on data activity in a table. A trigger may fire based on UPDATE, INSERT, or DELETE operations.

In SQL Server 2000, triggers can be fired after an operation completes (SQL Server default) or instead of the triggering operation. An AFTER TRigger can be used to archive data when it is deleted, to send a notification that the new data has been added or changed, or to initiate any other process you might want to automate based on data activity. An INSTEAD OF trigger can be used to perform more advanced activities (such as advanced data checking), to enable updates in a view to occur across multiple tables, and to perform many other functions that might be necessary in place of a triggering activity.

Triggers represent a mechanism in which code can be executed based on activity in the data. Triggers are expanded on and fully illustrated in Chapter 6.



    EXAM CRAM 2 Designing and Implementing Databases with SQL Server 2000 Enterprise
    MCAD/MCSE/MCDBA 70-229 Exam Cram 2: Designing & Implementing Databases w/SQL Server 2000 Enterprise Edition
    ISBN: 0789731061
    EAN: 2147483647
    Year: 2005
    Pages: 154

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net