Home > SQLServer, Working With Data > SQL Server – DDL vs. DML Triggers

SQL Server – DDL vs. DML Triggers


Although, DML and DDL triggers are used for different purposes, there are some similarities and differences between these.

 

Similarities between DDL and DML triggers:

1. Both are created using similar T-SQL syntax

2. Both can run .NET code

3. You can create multiple DDL and/or DML triggers on an object

4. The trigger and the triggering statement run as part of the same transaction

5. Both type of triggers can be nested

 

Differences between DDL and DML triggers:

1. There are no INSTEAD OF DDL triggers, they are only executed after the triggering statement is completed.

2. DML triggers use virtual tables INSERTED and DELETED which captures data modification, DDL triggers do not have this

3. DDL triggers captures information about the event that fired them using EVENTDATA() function.

 

Hope This Helps!

Vishal

  1. Rahul Jagtap
    08.12.2012 01:05 | #1

    Hi Vishal,

    Your post of below line on “http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/7cfc7777-be11-47ac-a356-0048ffbaac41” made a big difference , I was struggling a lot to do the thing on batch file and you below line made a big difference to my efforts. Thanks a lot !

    —> Please note that error can be captured only if severity level is greater than 10.

  1. No trackbacks yet.