---
title: "Explain about DML trigger with an example."  
description: "Explain about DML trigger with an example."  
author: "Ashutosh Patel"  
published: 2023-03-22  
updated: 2023-03-30  
canonical: https://www.mindstick.com/forum/157517/explain-about-dml-trigger-with-an-example  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 1 minute  

---

# Explain about DML trigger with an example.

[Explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) about [DML](https://www.mindstick.com/interview/23007/ddl-vs-dml) [trigger](https://www.mindstick.com/blog/167/triggers-in-wpf) with an example.

## Replies

### Reply by Krishnapriya Rajeev

Data Manipulation Language (DML) triggers are fired in response to events caused by DML statements like *INSERT, UPDATE, and DELETE*. They can also be triggered by system-defined stored procedures that perform operations similar to DML statements. These triggers can be used to ensure data integrity and also to query other tables.

There are two types of DML triggers:

a. AFTER Trigger\
It is fired when the SQL server action that triggered it is completed. It is typically executed whenever an INSERT, UPDATE, or DELETE operation on a table is completed.

Example:

![Explain about DML trigger with an example.](https://www.mindstick.com/mindstickforums/2d00b034-7cc6-4509-8257-1d4c6a2b88bb/images/4d75b1c8-59d8-49c9-a8d3-b16e0c441edf.png)

b. INSTEAD OF Trigger

It is fired before the SQL server begins executing the action that triggers it. Hence, the trigger will fire even if the constraint check fails.

Example:

![Explain about DML trigger with an example.](https://www.mindstick.com/mindstickforums/2d00b034-7cc6-4509-8257-1d4c6a2b88bb/images/bae67d8e-6dd8-4401-9cec-5557b3a25226.png)


---

Original Source: https://www.mindstick.com/forum/157517/explain-about-dml-trigger-with-an-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
