Monday, August 31, 2009

MCTS 70-433 DDL event triggers - "AFTER DROP TABLE"

The "AFTER DROP TABLE" is just one of many DDL events you can associate a trigger with:


Trigger on a CREATE, ALTER, DROP, GRANT, DENY, REVOKE, or UPDATE STATISTICS statement (DDL Trigger)

CREATE TRIGGER trigger_name 

ON { ALL SERVER | DATABASE } 

[ WITH [ ,...n ] ]

{ FOR | AFTER } { event_type | event_group } [ ,...n ]

AS { sql_statement  [ ; ] [ ,...n ] | EXTERNAL NAME <>  [ ; ] }


::=

    [ ENCRYPTION ]

    [ EXECUTE AS Clause ]


http://msdn.microsoft.com/en-us/library/ms189799.aspx


There are lots of DDL events, here are a few:


CREATE_SPATIAL_INDEX

ALTER_INDEX can be used for spatial indexes.

DROP_INDEX can be used for spatial indexes.

CREATE_STATISTICS

DROP_STATISTICS

UPDATE_STATISTICS

CREATE_SYMMETRIC_KEY

ALTER_SYMMETRIC_KEY

DROP_SYMMETRIC_KEY

CREATE_SYNONYM

DROP_SYNONYM

 

CREATE_TABLE

ALTER_TABLE (Applies to the ALTER TABLE statement and sp_tableoption.)

DROP_TABLE

CREATE_TRIGGER

ALTER_TRIGGER (Applies to the ALTER TRIGGER statement and sp_settriggerorder.)

DROP_TRIGGER


http://msdn.microsoft.com/en-us/library/bb522542.aspx



No comments: