Creating a Trigger
See Also
A trigger is a database object that you create by specifying:
-
The current table.
-
The data modification transactions that activate the trigger: adding new data (INSERT), updating existing data (UPDATE), or deleting existing data (DELETE).
-
The actions that the trigger will take immediately following the transactions you specified.
You write triggers in Transact-SQL for Microsoft® SQL Server™ databases or PL/SQL for Oracle databases.
To create a trigger
-
In Data View, expand the Tables folder.
-
Right-click the name of the table that you want to create a trigger on.
-
Choose New Trigger from the shortcut menu.
-
A new trigger is created in a source code editor with the default SQL statements already defined for you.
-
Modify the default trigger text as follows:
Replace |
With |
TABLE1_Trigger1 |
The name you want to assign to the trigger |
dbo.TABLE1 |
The name of the table you want to attach the trigger to |
/*Insert, Update, Delete*/ |
The type of transactions that will activate this trigger |
/*If Update (column_name) …*/ |
The transactions that will take place |
-
Write the remaining trigger text in SQL.
For syntax and examples of triggers, see your database documentation.