Click here to Skip to main content
15,887,326 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My page is run many times correctly.But now this error is appear:

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

i have a function in it that works well.

i dont have any stored procedure or trigger.

i dont know why this happenes!!

alter FUNCTION [dbo].[groupPath](@PostGroupID bigint) 
RETURNS nvarchar(100)
AS
BEGIN
declare @parent bigint 	
declare @ReturnPath nvarchar(100)
set @parent=(select PostGroupParentID from tblBase_PostGroup where PostGroupID=@PostGroupID)
if(@parent <>-1)
begin 
set @ReturnPath=(dbo.groupPath(@parent))
set @ReturnPath=@ReturnPath+'  »  '+(Select PostGroupName from tblBase_PostGroup where PostGroupID=@PostGroupID)
end
else
set @ReturnPath=(select PostGroupName from tblBase_PostGroup where PostGroupID=@PostGroupID)
return @ReturnPath
END;
Posted
Updated 11-Apr-12 19:56pm
v3
Comments
Ankur\m/ 12-Apr-12 2:11am    
I would suggest, add a breakpoint and debug the query. See why it is nesting so deep.

As the error message says, the nesting level of the function has exceeded the maximum limit allowed. You will have to analyse your function why it is so deeply nested. There are some good discussions here[^].
If you are still not able to solve the issue, you will have to post the code here.
 
Share this answer
 
Comments
Uday P.Singh 12-Apr-12 1:38am    
Correct 5!
The error means you're calling a procedure, view or function from your procedure, and then from that proc calling another, etc 32 levels deep. Or it could be recursive with the proc calling itself.

Either way, you're going to have to track down where that is coming from and change the code of your function so that the nesting level isn't anywhere close to that deep. There's no way to change the maximum nesting level.

For more information Read This[^]

hope it helps :)
 
Share this answer
 
Comments
Ankur\m/ 12-Apr-12 2:07am    
Man, that is copied word-to-word from http://www.sqlservercentral.com/Forums/Topic642288-9-1.aspx#_ctl5_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl13_lblFullMessage.
Please quote a reference when you do that or it will be cartogerized as plagiarized.
SQL
User Go keyword between exec procedure and final end
or simply alter only procedure not exec procedure command
 
Share this answer
 
The problem was not in Function.It was in my data that i entered.
In a record ,the PostGroupParentID field and PostGroupID were the same Number!

so the loop was happened!
I change the PostGroupParentID ,then the problem was solved!
 
Share this answer
 
v2
ALTER your database for RECURSIVE_TRIGGERS.
Quote:
If nested triggers are allowed and a trigger in the chain starts an infinite loop, the nesting level is exceeded and the trigger terminates. That time you do get this error. so simply rune this query.

SQL
USE yourdatabase
 GO
    -- Turn recursive triggers OFF in the database.
      ALTER DATABASE yourdatabase
      SET RECURSIVE_TRIGGERS OFF
GO


Hope your problem will resolve.
 
Share this answer
 
Comments
CHill60 8-May-14 4:23am    
OP posted that it was the data at fault ... 2 years ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900