Skip to content

DELETE Triggers

2008 July 28
by Shannon Lowder

This is the last of my three posts on triggers. We’ve already covered INSERT and UPDATE TRIGGERS. This time we’re doing DELETE triggers. All the same rules apply to DELETE triggers that apply to INSERT and UPDATE triggers.

CREATE TRIGGER t_tablename_delete
ON TableName
    T-SQL code

Just like for the INSERT TRIGGER, we can either run the T-SQL code after the DELETE (and all cascade change) has completed, or we can do the code INSTEAD OF the update.

Remember that AFTER and FOR are synonyms.

In INSERT triggers you gained access to the temporary table inserted. During UPDATE triggers, you gained access to the updated table. For deleted triggers, you gain access to deleted. This temporary table is only accessible from the T-SQL code you include in the body of the TRIGGER.

That’s pretty much all there is to an DELETE TRIGGER. If you have any questions, please, let me know. I’m here to help!

One Response leave one →

Trackbacks and Pingbacks

  1. Microsoft Exam 70-433 (part 2) | Shannon Lowder

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS