T-SQL Tutorial

T-SQL Create Trigger


Create Trigger Syntax

DML Trigger

CREATE TRIGGER trig_name
ON { table_name | view_name }
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
AS { sql_statement [ ; ] }
GO





DDL Trigger

CREATE TRIGGER trig_name
ON { ALL SERVER | DATABASE }
{ FOR | AFTER }
{ CREATE, ALTER, DROP, GRANT, DENY, REVOKE, UPDATE STATISTICS }
AS { sql_statement [ ; ] }
GO

Logon Trigger

CREATE TRIGGER trig_name
ON ALL SERVER
{ FOR| AFTER }
LOGON
AS { sql_statement [ ; ] }
GO

See also:
SQL Server -> Create DML Trigger Example