How To Create a DML Trigger using CREATE TRIGGER Statements?
Submitted by: AdministratorA 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 ggl_users table. It does nothing but printing a simple static message.
USE GlobalGuideLineDatabase;
GO
CREATE TRIGGER dml_message ON ggl_users
AFTER INSERT, UPDATE, DELETE
AS
PRINT 'Records are inserted, updated,'
+ ' or deleted in ggl_users';
GO
Command(s) completed successfully.
A simple DML trigger is defined on ggl_users now.
Submitted by: Administrator
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 ggl_users table. It does nothing but printing a simple static message.
USE GlobalGuideLineDatabase;
GO
CREATE TRIGGER dml_message ON ggl_users
AFTER INSERT, UPDATE, DELETE
AS
PRINT 'Records are inserted, updated,'
+ ' or deleted in ggl_users';
GO
Command(s) completed successfully.
A simple DML trigger is defined on ggl_users now.
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | How To Create a View on an Existing Table in MS SQL Server? |
☺ | What Are the Advantages of Passing Name-Value Pairs as Parameters? |
☺ | How to download and install the scaled-down database AdventureWorksLT? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |