subject:sp_setTriggersorder
syntax:sp_setTriggersorder [ @Triggersname= ] "triggers_name", [ @order= ] { "first" | "last" | "none" }, [ @stmttype= ] "statement_type"
content:ใช้จัดลำดับการทำงานให้กับ Triggers แบบ FOR TRIGGERS หรือ AFTER TRIGGERS
โดยสามารถจัดลำดับได้เฉพาะ first หรือ last เท่านั้น
example:CREATE TABLE tbl_orders
(
id int IDENTITY NOT NULL,
price money NOT NULL
)
GO
CREATE TRIGGERS trg_orders_1
ON orders
FOR INSERT, UPDATE
AS
PRINT "Occurs Modify Data In Orders Table 1."
GO
CREATE TRIGGERS trg_orders_2
ON orders
FOR INSERT, UPDATE
AS
PRINT "Occurs Modify Data In Orders Table 2."
GO
exec sp_setTriggersorder "trg_orders_1", "last"
exec sp_setTriggersorder "trg_orders_2", "first"
GO