SQL Server triggers - order of execution

前端 未结 10 1196
旧时难觅i
旧时难觅i 2020-12-16 09:39

Does anyone know how SQL Server determines the order triggers (of same type, i.e. before triggers) are executed. And is there any way of changing this so that I can specify

10条回答
  •  醉话见心
    2020-12-16 10:17

    Use This :

    For example :

    USE AdventureWorks;
    GO
    EXEC sys.sp_settriggerorder @triggername = N'', -- nvarchar(517)
        @order = '', -- varchar(10)
        @stmttype = '', -- varchar(50)
        @namespace = '' -- varchar(10)
    

    The First and Last triggers must be two different triggers.

    First : Trigger is fired first.

    Last : Trigger is fired last.

    None : Trigger is fired in undefined order.

    And see this link for value of @stmttype : DDL Events

    And for @namespace = { 'DATABASE' | 'SERVER' | NULL } and for more information see : DDL Triggers

提交回复
热议问题