Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How would i merge 4 Triggers to fire in sequence?

Posted on 2006-11-02
8
Medium Priority
?
191 Views
Last Modified: 2007-01-01
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!
0
Comment
Question by:bmanmike39
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17859241
well, simply merge the code of the 4 triggers in the order you want to run it...
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17859247
sp_settriggerorder
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 2000 total points
ID: 17859288
to set the trigger firing order

sp_settriggerorder @triggername= 'MyTrigger', @order='first'

or if its merging everything together, is it after triggers for different actions

if so as angel suggested

CREATE TRIGGER trig2
ON table
FOR INSERT, UPDATE
AS
   ur logic
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:bmanmike39
ID: 17859559
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'
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17859684
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.
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17859692
is all the triggers for update action on table2 ?

if so they can be merged as angel suggested
0
 

Author Comment

by:bmanmike39
ID: 17859853
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?
0
 
LVL 20

Expert Comment

by:Sirees
ID: 17859890
<<does that mean just put the queries in the order they must happen in the one trigger, one after another?>>

Yes.
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question