Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 set order of triggers

Author  Topic 

j-in-nz
Starting Member

17 Posts

Posted - 2007-04-02 : 18:52:03
I have 3 tables
on update of SETUP table I execute a trigger to update a field in TABLE1 where TABLE2.field = something. The problem is that TABLE1 has a trigger to update TABLE2. So the value is getting set before the 1st trigger is executed.
How can I set the order of the triggers?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-02 : 19:03:32
If you are using AFTER trigger, the trigger is executed AFTER the insert or update. use INSTEAD OF TRIGGER ?

or drop all trigger and perform the necessary updates in the sequence that you want with Stored Procedure.


KH

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-04-02 : 19:16:47
I''m not sure if this will solve your issue, but you might take a look at: sp_settriggerorder in BOL.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-02 : 19:22:37
sp_settriggerorder is for a table. What j-in-nz have is different table.

quote:
sp_settriggerorder
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.





KH

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-04-03 : 09:52:22
Another prime example where sproc only access isthe way to go



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -