after delete/insert和 for delete/insert的区别

解决方案 »

  1.   

    AFTER 
    Specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.AFTER is the default when FOR is the only keyword specified. AFTER triggers cannot be defined on views. INSTEAD 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 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. 
      

  2.   

    after显然是更改后呀
    for是为了嘛
      

  3.   

    AFTER 
    触发器在触发它们的语句完成后执行。如果该语句因错误(如违反约束或语法错误)而失败,触发器将不会执行。不能为视图指定 AFTER 触发器,只能为表指定该触发器。可以为每个触发操作(INSERT、UPDATE 或 DELETE)指定多个 AFTER 触发器。如果表有多个 AFTER 触发器,可使用 sp_settriggerorder 定义哪个 AFTER 触发器最先激发,哪个最后激发。除第一个和最后一个触发器外,所有其它的 AFTER 触发器的激发顺序不确定,并且无法控制。在 SQL Server 2000 中 AFTER 是默认触发器。不能在 SQL Server 7.0 版或更早的版本中指定 AFTER 或 INSTEAD OF,这些版本中的所有触发器都作为 AFTER 触发器运行。INSTEAD OF 
    该触发器代替触发操作执行。可在表和视图上指定 INSTEAD OF 触发器。只能为每个触发操作(INSERT、UPDATE 和 DELETE)定义一个 INSTEAD OF 触发器。INSTEAD OF 触发器可用于对 INSERT 和 UPDATE 语句中提供的数据值执行增强的完整性检查。INSTEAD OF 触发器还允许指定某些操作,使一般不支持更新的视图可以被更新。