BLOGS BY TOPIC
BLOGS BY AUTHOR
BLOGS BY YEAR
Triggers are special stored procedures that execute automatically in response to certain events in a database. This blog explains how to create three types of trigger in SQL Server: DML, DDL and Logon triggers.
This blog is part of our free SQL Server tutorial.
Posted by Andrew Gould on 27 November 2013
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Triggers in SQL Server
In SQL Server, a trigger is a special type of stored procedure which will run automatically in response to some kind of event in the database.
Types of Trigger
There are three main types of trigger in SQL Server, as described in the table below:
|DML Trigger||DML, or Data Manipulation Language triggers respond to events which manipulate the data in your database. Typically, this type of trigger would be attached to events such as INSERT, UPDATE or DELETE statements which change the data in a table or a view.|
|DDL Trigger||A DDL, or Data Definition Language trigger would be executed when objects within a database are modified. CREATE, ALTER and DROP are good examples of statements which could execute a DDL trigger.|
|Logon Trigger||Logon triggers are fired when a user session is being established.|
What This Blog Covers
This blog covers all three types of trigger, starting with the DML variety on the next page.