all groups > sql server programming > march 2007 >
You're in the

sql server programming

group:

Recursive "Instead of" Trigger


Re: Recursive "Instead of" Trigger Tibor Karaszi
3/5/2007 8:48:59 PM
sql server programming:
Can you point to where BOL states that instead of triggers fires recursively? Also, what version
(2000 or 2005) and what update do you have of Books Online? Below is a quote from my 2005 Books
Online, most recent refresh:

If an INSTEAD OF trigger defined on a table executes a statement against the table that would
ordinarily fire the INSTEAD OF trigger again, the trigger is not called recursively. Instead, the
statement is processed as if the table had no INSTEAD OF trigger and starts the chain of constraint
operations and AFTER trigger executions. For example, if a trigger is defined as an INSTEAD OF
INSERT trigger for a table, and the trigger executes an INSERT statement on the same table, the
INSERT statement executed by the INSTEAD OF trigger does not call the trigger again. The INSERT
executed by the trigger starts the process of performing constraint actions and firing any AFTER
INSERT triggers defined for the table.



--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


[quoted text, click to view]
Recursive "Instead of" Trigger Leila
3/5/2007 11:12:49 PM
Hi,
BOL states that "Instead Of" triggers can be fired recursively but I could
not experience it by a simple table and trigger. It works fine with After
triggers. Are there any special consideration?
Thanks in advance,
Leila

Re: Recursive "Instead of" Trigger Leila
3/6/2007 11:09:24 PM
Hi Tibor,
I could find the paragraph which you posted here in CREATE TRIGGER statement
in my BOL. But this is what I think it implies recursion of Instead Of
triggers:

Both DML and DDL triggers are nested when a trigger performs an action that
initiates another trigger or executes managed code by referencing a CLR
routine, type, or aggregate. These actions can initiate other triggers, and
so on. DML and DDL triggers can be nested up to 32 levels. You can control
whether AFTER triggers can be nested through the nested triggers server
configuration option. INSTEAD OF triggers (only DML triggers can be INSTEAD
OF triggers) can be nested regardless of this setting.

My BOL is April 2006, SQL Server 2005 Developer Edition SP2.

Thanks



"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:eyInQ91XHHA.1296@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

Re: Recursive "Instead of" Trigger Tibor Karaszi
3/7/2007 12:00:00 AM
I see what you mean.

In this context, nested triggers refer to you modify table A, it has a trigger that modifies table
B. If table B has a trigger, would it fire? In other words, nesting refers to A modifies B, which
modifies C, which modifiers D etc.

Where recursive means A modifies A which modifies A which modifies A. Or, A modifies B which
modifies A which modifies B etc.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Re: Recursive "Instead of" Trigger Leila
3/7/2007 12:00:00 AM
Thanks for clarification!


"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:%23cNjkrIYHHA.1296@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button