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 2000 Forums
 SQL Server Development (2000)
 Nested Trigger

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-12-26 : 06:50:26
Hi,
I wanted to know, in what order does Triggers get fire?

So, I created Tab1 and defined two triggers on it, i.e. Trg_One and Trg_Two, both are AFTER INSERT.

when I tried to execute insert command on Tab1 I got an error, ie.

Msg 217, Level 16, State 1, Procedure Trg_One, Line 5
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).


Can anybody tell me, how to overcome this problem, rather I would like to know how to set the NestLevel and what is the max limit of NestLevel?

Also I will be very thankful, if anybody will tell me, in what order does the triggers get fired?

Thanks in advance,

Mahesh

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-26 : 06:56:57
I believe yours is the case of infinite loop of indirect recursive triggers. For example, Trigger A does some action which fires Trigger B which again does some action which fires Trigger A and so on. SQL Server will continue in this fashion till max nesting level is reached which is 32.

You can't control firing order of each trigger but you can set which trigger should be first and which should be last using sp_settriggerorder.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-12-26 : 07:01:43
quote:
Originally posted by harsh_athalye

I believe yours is the case of infinite loop of indirect recursive triggers. For example, Trigger A does some action which fires Trigger B which again does some action which fires Trigger A and so on. SQL Server will continue in this fashion till max nesting level is reached which is 32.

You can't control firing order of each trigger but you can set which trigger should be first and which should be last using sp_settriggerorder.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



Agree, but Harsh I need to set the NestLevel to some upper limit coz currently my NestLevel is 0 [Zero]. I have set the trigger firing action to First and Last

Thanks,

Mahesh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-26 : 07:06:59
Refer this. Might be of help:-

[url]http://www.eggheadcafe.com/software/aspnet/31374640/trigger-nesting-level-exc.aspx[/url]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-26 : 07:35:26
and can yoo post your trigger code?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -