Code that SQL Server runs automatically, inside the same transaction, whenever someone tries an INSERT, UPDATE or DELETE on a table or view. It can query the inserted and deleted tables to see what changed.
Read more: Microsoft Learn
In the Ultra Transcenders books
Each book explains DML trigger in context, with comparison tables and the common traps.
Terms in this definition
- Microsoft SQL Server
Microsoft's database engine. It can hold Veeam's configuration database in place of PostgreSQL, and is protected with a dedicated plug-in, Veeam Explorer, and application-aware processing plus log backup.
- Agents (classic) API
First-generation Foundry Agent Service API, based on threads, messages and runs. It is deprecated, replaced by conversations and responses, and retires on 31 March 2027.
- INSERT
Adds fresh rows to a table. You list the target columns and supply a value for each; it is part of Data Manipulation Language (DML).
- CRUD
Shorthand for create, read, update and delete, the four basic things you do with data. Data-plane roles in Azure Cosmos DB, for instance, authorise those operations on items.
- Event
Table in Log Analytics where entries from Windows event logs are kept.
- View
Shows a system through one chosen group of related concerns. No view is generic; each one is tied to whichever architecture it depicts.
- CAN QUERY
Lets the holder query a serving endpoint. In the permission ladder, it is one step up from CAN VIEW and one below CAN MANAGE.
- inserted and deleted tables
Two temporary tables held in memory that a DML trigger can read: one contains the rows as they look after the change, the other as they looked before it.
Related terms
- AFTER trigger
A DML trigger that fires once the statement that caused it, and its constraint checks, have completed successfully, still within that transaction. It can only be defined on tables; to replace an action, or to work on a view, use an
INSTEAD OFtrigger. - INSTEAD OF trigger
A DML trigger that replaces the INSERT, UPDATE or DELETE statement that set it off. A common use is letting a view accept changes by applying them to the tables underneath.