Link to home
Start Free TrialLog in
Avatar of bmanmike39
bmanmike39

asked on

How would i merge 4 Triggers to fire in sequence?

Can someone show me a sample of  how to merge my 4 triggers, to fire in sequence.

It’s kind of urgent that i find a solution to this problem ASAP.

I’m just learning Tsql, and know only the basics.

Any help would be appreciated!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

well, simply merge the code of the 4 triggers in the order you want to run it...
Avatar of Gautham Janardhan
Gautham Janardhan

sp_settriggerorder
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bmanmike39

ASKER

My understanding of the sp_settriggerorder is that i can only set the first and last trigger, and the other will fire in undefined order.
I need each to fire in defined order to update.  I thought the article also said setting the first trigger to update would cause a error.

Is my code correct? Is what i should would do?

CREATE TRIGGER   TriggerAll
ON    table2
FOR   UPDATE
AS
 
sp_settriggerorder @Triggeroder1= 'Trigger1', @order='first'
sp_settriggerorder @Triggeroder2= 'Trigger2',
sp_settriggerorder @Triggeroder= 'Trigger3',
sp_settriggerorder @Triggeroder= 'Trigger4, @order='last'
u r right

Specifies which AFTER triggers associated with a table will be fired first or last. The AFTER triggers that will be fired between the first and last triggers will be executed in undefined order.
is all the triggers for update action on table2 ?

if so they can be merged as angel suggested
Yes

I do not know how to merge the updates,  does that mean just put the queries in the order they must happen in the one trigger, one after another?
<<does that mean just put the queries in the order they must happen in the one trigger, one after another?>>

Yes.