Section courante

A propos

Section administrative du site

CREATE TRIGGER

Crée un déclencheur
  Microsoft SQL Server

Syntaxe

CREATE TRIGGER [ schema_name . ]trigger_name
ON { table | view }
[ WITH dml_trigger_option [ ,...n ] ]
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME method specifier [ ; ] }

dml_trigger_option ::=
[ ENCRYPTION ]
[ EXECUTE AS Clause ]

method_specifier ::=
assembly_name.class_name.method_name
Déclenchement sur une instruction INSERT, UPDATE ou DELETE vers une table ou une vue (déclencheur DML)
CREATE TRIGGER [ schema_name . ]trigger_name ON { table }
[ WITH dml_trigger_option [ ,...n ] ]
{ FOR | AFTER }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
AS { sql_statement [ ; ] [ ,...n ] }

dml_trigger_option ::=
[ NATIVE_COMPILATION ]
[ SCHEMABINDING ]
[ EXECUTE AS Clause ]
Déclenchement sur une instruction INSERT, UPDATE ou DELETE vers une table (déclencheur DML sur les tables optimisées en mémoire)
CREATE TRIGGER trigger_name
ON { ALL SERVER | DATABASE }
[ WITH ddl_trigger_option [ ,...n ] ]
{ FOR | AFTER } { event_type | event_group } [ ,...n ]
AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME method specifier [ ; ] }

ddl_trigger_option ::=
[ ENCRYPTION ]
[ EXECUTE AS Clause ]
Déclenchement sur une instruction CREATE, ALTER, DROP, GRANT, DENY, REVOKE ou UPDATE (déclencheur DDL)
CREATE TRIGGER trigger_name
ON ALL SERVER
[ WITH logon_trigger_option [ ,...n ] ]
{ FOR| AFTER } LOGON
AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME method specifier [ ; ] }

logon_trigger_option ::=
[ ENCRYPTION ]
[ EXECUTE AS Clause ]
Déclenchement sur un événement LOGON (déclencheur Logon)

Description

Cette instruction permet de créer la définition d'un DML, DDL ou d'un déclencheur de connexion.



Dernière mise à jour : Vendredi, le 19 Juin 2020