I know about "Allow Triggers to Fire Others" server setting that allows the action taken by a trigger to fire another trigger (or not), and as I understand it, my only options are True (allow trigger to fire other triggers, which may lead to unending recursion) or False (actions taken by triggers will not fire any other triggers, which may lead to unexpected results or inconsistent data).
Is there a way to enforce a "Maximum trigger depth" in SQL Server? I'm using 2008, if it matters, though I'm not aware of the feature on any version (or in any other RDBMS, for that matter, though my knowledge is admittedly limited). For example, here's what I'd like:
Does anybody out there know if this is possible, or if there's an outstanding feature request for this behavior? If I'm crazy and this is a terrible idea for behavior, I'm open to that, but I'd like to know why (unintentional consequences, etc).
Inside a trigger, you can check the nesting level, and optionally return:
IF (TRIGGER_NESTLEVEL() > 2)
RETURN
See this blog post for more details.