Triggers are for INSERT, UPDATE, or DELETE only.
triggers are for INSERT, UPDATE, or DELETE only.
There are also DDL triggers for a wide variety of DDL events. I answered wrong because I thought that TRUNCATE could generate a DDL event :-)
Actually TRUNCATE looks like a DDL statement, because it requests a schema modification lock:
CREATE TABLE test (a INT)
TRUNCATE TABLE test
WHERE request_session_id = @@SPID
AND resource_type = 'OBJECT'
AND resource_associated_entity_id = OBJECT_ID('test')
DROP TABLE test
In the example above, we will see request_mode = Sch-M (schema modification). This is specific to DDL events.