How to Fire a trigger when you do TRUNCATE (instead deleted) in MSSQL
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
TRUNCATE TABLE cannot be used when a foreign key references the table to be truncated, since TRUNCATE TABLE statements do not fire triggers. This could result in inconsistent data because ON DELETE / ON UPDATE triggers would not fire.
To achieve high performance, TRUNCATE TABLE bypasses the DML method of deleting data. Thus, it does not cause ON DELETE triggers to fire, it cannot be performed for InnoDB tables with parent-child foreign key relationships, and it cannot be rolled back like a DML operation.
No, TRUNCATE is a DDL statement and does not fire any trigger on that table.
From msdn:
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
You can't do this on SQL server.
From MSDN
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. For more information, see CREATE TRIGGER (Transact-SQL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With