Kerala Microsoft Users Group
Pay $0.00 for Windows Server 2008 and SQL Server 2008 licenses.

Stored Procedure Nesting Level

Latest post 12-03-2009 12:57 AM by NinethSense. 6 replies.
  • 11-30-2009 5:30 AM

    Stored Procedure Nesting Level

     

     Hi All,

     

               Can anyone explain how to increase the nesting level of a stored procedure in SQL Server 2005 ???

     

     when  executing the stored procedure i'm getting  the following error ..............

    Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

     

    Regards

    Razik

    • Post Points: 25
  • 11-30-2009 6:04 AM In reply to

    Re: Stored Procedure Nesting Level

    Not sure if it is possible. In my knowledge it is not possible to increase the limit and you need to change your logic.

    MSDN says:

    Nested Triggers

    Triggers can be nested to a maximum of 32 levels. If a trigger changes a table on which there is another trigger, the second trigger is activated and can then call a third trigger, and so on. If any trigger in the chain sets off an infinite loop, the nesting level is exceeded and the trigger is canceled. To disable nested triggers, set the nested triggers option of sp_configure to 0 (off). The default configuration allows for nested triggers. If nested triggers is off, recursive triggers is also disabled, regardless of the RECURSIVE_TRIGGERS setting set by using ALTER DATABASE.

    Source: http://msdn.microsoft.com/en-us/library/ms189799(SQL.90).aspx

    PraVeeN
    Microsoft MVP
    blog.ninethsense.com | kidoos.net

    • Post Points: 25
  • 12-01-2009 6:23 AM In reply to

    • Renju
    • Top 50 Contributor
    • Joined on 04-18-2009
    • Chennai/Alapuzha
    • Newbie
    • Points 310

    Re: Stored Procedure Nesting Level

     Nesting limit is 32 levels, SQL Server has no limit on the number of stored procedures that can be invoked from a given stored procedure, provided that the subordinate stored procedures do not invoke other subordinate stored procedures and the maximum nesting level is never exceeded.

    You can view the nesting count using

    select

     

     

    @@NESTLEVEL

    Refer this also : http://www.daniweb.com/forums/thread114466.html

    Regards

    REnju

    http://blog.renjucool.com

    Filed under:
    • Post Points: 25
  • 12-02-2009 1:57 AM In reply to

    Re: Stored Procedure Nesting Level

    Hi All,

     

             I got an alternative for recursive stored procedures, I used CTE (common table expressions) for recursive calling.

            I want to know is there any limitations for this also ?? How far it is effective in comparison with the other methods ???

     

    Regards

    Razik

    • Post Points: 25
  • 12-02-2009 3:08 AM In reply to

    Re: Stored Procedure Nesting Level

    I have not used it yet but heard it is very reliable for complex tasks. Go ahead.

    http://msdn.microsoft.com/en-us/library/ms186243.aspx

    PraVeeN
    Microsoft MVP
    blog.ninethsense.com | kidoos.net

    • Post Points: 25
  • 12-02-2009 9:33 AM In reply to

    • Renju
    • Top 50 Contributor
    • Joined on 04-18-2009
    • Chennai/Alapuzha
    • Newbie
    • Points 310

    Re: Stored Procedure Nesting Level

    Yes CTE is good approach Praveen.

     

    Regards

    Renju.R

    SQL Server Performance Engineer

    • Post Points: 25
  • 12-03-2009 12:57 AM In reply to

    Re: Stored Procedure Nesting Level

    Thanks for the clarification Renju

    PraVeeN
    Microsoft MVP
    blog.ninethsense.com | kidoos.net

    • Post Points: 5
Page 1 of 1 (7 items) | RSS
Pay $0.00 for Windows Server 2008 and SQL Server 2008 licenses.