Solved

How would i merge 4 Triggers to fire in sequence?

Posted on 2006-11-02
8
179 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
sp_settriggerorder
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
Comment Utility
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
 

Author Comment

by:bmanmike39
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 29

Expert Comment

by:Gautham Janardhan
Comment Utility
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
Comment Utility
is all the triggers for update action on table2 ?

if so they can be merged as angel suggested
0
 

Author Comment

by:bmanmike39
Comment Utility
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
Comment Utility
<<does that mean just put the queries in the order they must happen in the one trigger, one after another?>>

Yes.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now