当前位置: 代码迷 >> SQL >> sql2005触发器有关问题,麻烦高手们讲解一下
  详细解决方案

sql2005触发器有关问题,麻烦高手们讲解一下

热度:394   发布时间:2016-05-05 15:34:39.0
sql2005触发器问题,麻烦高手们讲解一下.
如create trigger t_name
on{table|view}
{{for|after|instead of}
 {[delete][,][insert][,][update]}
as sql_statement
}
其中FOR,AFTER,INSTEAD OF是什么意思?分别用于什么情形,他们的区别是什么.

------解决方案--------------------
楼主首先要学习的是如何查阅在线帮助文档!


SQL Server 2005 Books OnlineINSTEAD OF
Specifies that the DML trigger is executed instead of the triggering SQL statement, therefore, overriding the actions of the triggering statements. INSTEAD OF cannot be specified for DDL or logon triggers.

At most, one INSTEAD OF trigger per INSERT, UPDATE, or DELETE statement can be defined on a table or view. However, you can define views on views where each view has its own INSTEAD OF trigger.

INSTEAD OF triggers are not allowed on updatable views that use WITH CHECK OPTION. SQL Server raises an error when an INSTEAD OF trigger is added to an updatable view WITH CHECK OPTION specified. The user must remove that option by using ALTER VIEW before defining the INSTEAD OF trigger.

  相关解决方案