sql MS SQL触发器语法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MS SQL触发器语法相关的知识,希望对你有一定的参考价值。

-- DML TRIGGER
-- Trigger on an INSERT, UPDATE, or DELETE
CREATE|ALTER TRIGGER [schema_name.]trigger_name   
ON table|view
   [WITH ENCRYPTION|SCHEMABINDING|EXECUTE AS Clause]  
   FOR|AFTER|INSTEAD OF
   INSERT[,]|UPDATE[,]|DELETE
   [WITH APPEND]  
   [NOT FOR REPLICATION]   
AS 
  sql_statement  [ ; ] [ ,...n ] | 
  EXTERNAL NAME assembly_name.class_name.method_name 
  
-- DDL TRIGGER
-- Trigger on a CREATE, ALTER, DROP, GRANT,
-- DENY, REVOKE or UPDATE 
CREATE|ALTER TRIGGER trigger_name   
ON ALL SERVER | DATABASE 
   [WITH ENCRYPTION|EXECUTE AS Clause]  
   FOR|AFTER
   event_type|event_group
   [ ,...n ]  
AS 
  sql_statement  [ ; ] [ ,...n ] | 
  EXTERNAL NAME assembly_name.class_name.method_name 
  
-- LOGON TRIGGER
CREATE|ALTER TRIGGER trigger_name   
ON ALL SERVER   
   [WITH ENCRYPTION|EXECUTE AS Clause]  
   FOR|AFTER 
   LOGON    
AS
   sql_statement [ ; ] [ ,...n ] |
   EXTERNAL NAME assembly_name.class_name.method_name 

以上是关于sql MS SQL触发器语法的主要内容,如果未能解决你的问题,请参考以下文章

sql 插入触发器后的MS SQL

sql MS SQL在DB中获取所有触发器

sql MS SQL SP语法

sql MS SQL for XML语法

sql MS SQL用户定义的函数语法

Ms Sql插入触发器以影响其他表