?
Solved

Can I have a trigger within a trigger sql

Posted on 2011-05-11
4
Medium Priority
?
418 Views
Last Modified: 2012-05-11
I would like to know if i can create a trigger within a trigger?  I know i can create a process within a trigger but what about creating another trigger within it? if yes the how far in can i go?

Thanks
0
Comment
Question by:Squadless
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
dwe761 earned 1600 total points
ID: 35739980
0
 
LVL 14

Assisted Solution

by:Daniel_PL
Daniel_PL earned 400 total points
ID: 35740024
Are you asking about MS SQL Server or MySQL?
MS SQL Server supports the nesting of triggers up to a maximum of 32 levels.

Using Nested Triggers

SQL Server has global server option which can be used to disable nested triggers, but one should notice:

In SQL Server 2000, any AFTER trigger nested inside an INSTEAD OF trigger does not fire when the nested triggers server configuration option is off. In SQL Server 2005 or later, the first AFTER trigger nested inside an INSTEAD OF trigger fires even if the nested triggers server configuration option is set to 0. However, under this setting, later AFTER triggers do not fire. We recommend that you review your applications for nested triggers to determine whether the applications still comply with your business rules with regard to this behavior when the nested triggers server configuration option is set to 0, and then make appropriate modifications.
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35740041
It should be:
"SQL Server has global server option which can be used to disable AFTER nested triggers..."
0
 
LVL 40

Expert Comment

by:lcohan
ID: 35740050
I don't think you can "create a trigger within a trigger" however they can nest up to 32 levels as mentioned above. That means the action(s) INSERT/UPDATE/DELETE from one can fire up to 32 levels of other triggers by default in SQL. Just caution with what they do as they are hidden SQL objects and may significantly degrade performance.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

864 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