Sunday, August 22, 2010

SQL SERVER – Difference between DML Triggers and DDL Triggers

As we discussed earlier in the previous  article,  DML Triggers will be fired automatically whenever Data Manipulation statements like INSERT,UPDATE and DELETE are executed where as DDL triggers will fire with the Data definition statements like CREATE, ALTER and DROP.       

Now let us see the differences between these two types of triggers. 

DML Triggers

DDL Triggers

1. Operate on INSERT, UPDATE and DELETE

1. Operate on CREATE, DROP and ALTER

2. Applied on Tables and views
2. Applied on Databases and servers
3. Can be used as INSTEAD OF TRIGGERS 3. Cannot be used as INSTEAD OF TRIGGERS
4. Creates INSERTED and DELETED tables 4. Cannot Create INSERTED and DELETED tables
5. DML triggers run either Before or After a T-SQL statement is completed 5. DDL triggers run only after a T-SQL statement is completed

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.