x
login about faq Site discussion (meta-askssc)

Trigger differences

What is the difference between DDL and regular triggers? I keep seeing these terms in Books Online.

more ▼

asked Oct 19 '09 at 11:21 AM in Default

Steve Jones - Editor gravatar image

Steve Jones - Editor ♦♦
5.1k 74 78 82

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

A DDL trigger is something that works on changes to the schema of a database. They are scoped against the database. There are also server event/logon triggers, which work on extended events and are scopes against the server. A 'regular' trigger is a DML trigger, and executes either 'AFTER' or 'INSTEAD OF' an UPDATE, DELETE or INSERT statement, or any combination of the three.

A big difference is the way that the triggers deal with their scope data - DML triggers use the virtual table monikers 'inserted' and 'deleted' to reference the new and old values of data, respectively. DDL/server event/logon triggers use the EVENTDATA function to retrieve information about what happened.

more ▼

answered Oct 19 '09 at 12:05 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

(comments are locked)
10|1200 characters needed characters left

A nice quick article from MSDN on Understanding DDL Triggers vs DML Triggers:

http://msdn.microsoft.com/en-us/library/ms189599.aspx

more ▼

answered Oct 19 '09 at 12:25 PM

Jorge Segarra gravatar image

Jorge Segarra
419 2

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x913
x98

asked: Oct 19 '09 at 11:21 AM

Seen: 1226 times

Last Updated: Oct 19 '09 at 11:21 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.