Solved

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

Posted on 2014-01-03
3
4,251 Views
Last Modified: 2014-01-03
I have an cursor, it always gave nested errors where as we have on 5 subjects for B.Com and semester 1

alter procedure step1
@course varchar(200),
@semester int
as
begin
declare @tsubjectcode varchar(200)
declare @tcredits varchar(200)
declare db_step1 cursor for
select distinct subjectcode,credits from allsubjects
where course=@course and semester=@semester
order by 1
open db_step1
fetch next from db_step1 into @tsubjectcode,@tcredits
while @@fetch_status=0
begin
      select @tsubjectcode,@tcredits
fetch next from db_step1 into @tsubjectcode,@tcredits
end
close db_step1
deallocate db_step1
end

exec step1 'B.Com',1
0
Comment
Question by:searchsanjaysharma
3 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39754939
thats for nesting
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

this means that something that you are drawing information from in your stored procedure is more than 32  nested levels deep. Its obvoiusly not in the code above. You'll have to dig to find that elsewhere in one of your other functions thats your using in this SP.
0
 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 39755001
The reason is that you have exec step1 'B.Com', 1 in a line that will be part of the stored procedure.

So when you execute step1 you will be executing it and it will execute itself again while in the proc.

You need to put a GO between the end and the exec

alter procedure step1
@course varchar(200),
@semester int
as
begin
declare @tsubjectcode varchar(200)
declare @tcredits varchar(200)
declare db_step1 cursor for 
select distinct subjectcode,credits from allsubjects 
where course=@course and semester=@semester
order by 1
open db_step1
fetch next from db_step1 into @tsubjectcode,@tcredits
while @@fetch_status=0
begin
      select @tsubjectcode,@tcredits
fetch next from db_step1 into @tsubjectcode,@tcredits
end
close db_step1
deallocate db_step1
end 

GO

exec step1 'B.Com',1

Open in new window

0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39755217
tx
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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