Collections:
"CREATE TRIGGER" - Creating a DML Trigger in SQL Server
How To Create a DML Trigger using CREATE TRIGGER Statements in SQL Server?
✍: FYIcenter.com
A DML trigger is a trigger declared to handle a DML event, which occurs when an INSERT, UPDATE or DELETE statement is executed. If you want to create a DML trigger, you should use the "CREATE TRIGGER" statement in the following format:
CREATE TRIGGER trigger_name ON table_name AFTER INSERT, UPDATE, DELETE AS statements GO
The tutorial exercise below shows you a very simple DML trigger defined on the fyi_users table. It does nothing but printing a simple static message.
USE FyiCenterData;
GO
CREATE TRIGGER dml_message ON fyi_users
AFTER INSERT, UPDATE, DELETE
AS
PRINT 'Records are inserted, updated,'
+ ' or deleted in fyi_users';
GO
Command(s) completed successfully.
A simple DML trigger is defined on fyi_users now.
⇒ Testing DML Triggers in SQL Server
⇐ Creating a Simple Table to Test Triggers in SQL Server
2016-10-25, 2700🔥, 0💬
Popular Posts:
How to check if two JSON values have overlaps using the JSON_OVERLAPS() function? JSON_OVERLAPS(json...
What Happens to an Arithmetic Operation with Two Different Data Types in SQL Server Transact-SQL? Wh...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...