A client of Comprehensive Database Performance Health Check asked me questions about types of triggers. Let us learn about it.
Well, there are three main types of triggers.
- DDL Trigger – DDL trigger runs when Data Definition Language events occur in the database. DDL events are CREATE, ALTER and DROP statements.
- DML Trigger – DML trigger runs when Data Modification Language events occur in the database. DML events are INSERT, UPDATE, and DELETE statements.
- Logon Trigger – Logon triggers runs when Logon events happen in SQL Server. When you log in to the SQL Server instance, the triggers execute.
Do you use triggers for your business applications? I have stopped using them for many years and it has been fantastically fine. Let me know your thoughts in the comments.
Here are my few recent videos and I would like to know what is your feedback about them. Do not forget to subscribe SQL in Sixty Seconds series.
- MAX Columns Ever Existed in Table – SQL in Sixty Seconds #182
- Tuning Query Cost 100% – SQL in Sixty Seconds #181
- Queries Using Specific Index – SQL in Sixty Seconds #180
- Read Only Tables – Is it Possible? – SQL in Sixty Seconds #179
- One Scan for 3 Count Sum – SQL in Sixty Seconds #178
- SUM(1) vs COUNT(1) Performance Battle – SQL in Sixty Seconds #177
- COUNT(*) and COUNT(1): Performance Battle – SQL in Sixty Seconds #176
Reference: Pinal Dave (http://blog.SQLAuthority.com)
DML events include INSERT, UPDATE, or DELETE statements…
If I had the power to decide, I’d avoid triggers as well. But as most departments just buy software and make me implement it, the use of triggers is the choice of the unknown software developers of those products.
I only have 70 triggers using cursors in the current production server I am working on. So with business logic. 🤐