This question already has answers here:
what does if we change database to Recursive Triggers Enabled :True? (2 answers)
Closed 19 hours ago.
I have a scenario where I have table A
This table has a trigger on it when deleting (After Delete)
Within this trigger if I call a delete statement on table A (DELETE FROM TABLE A etc), I would think that this would cause the trigger to run again? Wouldn't it just loop forever and keep calling the trigger? It is not doing that, everything seems to be working normal but I cannot seem to figure this out.
Thanks in advance for any help.
1条答案
按热度按时间shstlldc1#
There are two types of recursion in SQL Server.
Nesting/recursion of a trigger in SQL Server depends on the
server trigger recursion
andnested triggers
configurations.Wouldn't it just loop forever and keep calling the trigger?
No. the maximum nesting level is 32 for SQL Server.
You can read about these configurations in below links server trigger recursion Server Configuration Option and Configure the nested triggers Server Configuration Option
You can read more on this in action in below article
A warning! You must ne careful using triggers especially in production environments. It may cause performance issues that may not be easy to figure out.
Hope this helps.