A trigger is a database object that you create by specifying:
You write triggers in Transact-SQL for MicrosoftSQL Server databases.
A new trigger is created in the SQL text source code editor with the default SQL statements already defined for you.
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 |
For syntax and examples of triggers, see the Microsoft SQL documentation.
Note Include both a RAISERROR statement and ROLLBACK transaction together in a trigger for situations when the trigger determines that a modification must be disallowed. This will ensure that the client record set stays in synch with the data at the server. If you include only the RAISERROR statement or ROLLBACK transaction, but not both, the client record set will not reflect the current state of the data at the server. The RAISERROR statement should be defined with a severity level greater than 10. For more information, see RAISERROR and ROLLBACK Transaction in the SQL Server documentation.