Solved

How would i merge 4 Triggers to fire in sequence?

Posted on 2006-11-02
8
182 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 500 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

828 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