Solved

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

Posted on 2014-01-03
3
4,045 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
A short film showing how OnPage and Connectwise integration works.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

948 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

19 Experts available now in Live!

Get 1:1 Help Now