SQL Server triggers - order of execution

前端 未结 10 1204
旧时难觅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:11

    You can guarantee which trigger is fired first, which trigger is fired last and which ones fire in the middle by using sp_settriggerorder. If you need to synchronize more than three it does not appear possible in SQL Server 2005.

    Here is a sample taken from here (The linked article has much more information).

    sp_settriggerorder [ @triggername = ] ‘[ triggerschema. ] triggername’
    , [ @order = ] ‘value’
    , [ @stmttype = ] ’statement_type’
    [ , [ @namespace = ] { ‘DATABASE’ | ‘SERVER’ | NULL } ]
    

提交回复
热议问题