Solved

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

Posted on 2014-01-03
3
3,901 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
Comment Utility
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
Comment Utility
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
Comment Utility
tx
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Backup & Restore 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.
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now