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
 General SQL Server Forums
 New to SQL Server Programming
 Trigger Issue

Author  Topic 

binucn
Starting Member

5 Posts

Posted - 2011-04-05 : 05:16:50
It seems my trigger are executing multiple times on a single update. What are the situations that a trigger can execute multiple time?

Please help

Thanks in Advance
Binu

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-05 : 07:34:39
The only cases I can think of are either via recursion or nesting.

If nested triggers option (at server level) is turned on this can happen. By default it is turned on.

If RECURSIVE_TRIGGERS is turned on (at database level), then again this can happen. By default it is turned off.

According to http://msdn.microsoft.com/en-us/library/ms190739.aspx "Only direct recursion of AFTER triggers is prevented when the RECURSIVE_TRIGGERS database option is set to OFF. To disable indirect recursion of AFTER triggers, also set the nested triggers server option to 0."
Go to Top of Page

binucn
Starting Member

5 Posts

Posted - 2011-04-06 : 00:13:20
Thank you very much for the reply.


This multiple execution of trigger does not happen every time. In my server nested trigger is set on. The Recursive-Triggerrs is OFF. This issue was reported by a user. Then only we found the issue. I ran an update on the Trigger Table and watched the result. But it was working smoothly.


Thanks
Binu
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-04-06 : 00:26:50
Are you able to post the code? Perhaps there's a bug in it that we can spot.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -