Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)
Database
1
Posts
1
Posters
0
Views
1
Watching
-
Hi All, I am getting the following error when I am running the stored procedure.
Msg 217, Level 16, State 1, Procedure rptClassInformation_sel, Line 26. Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).
When I remove the following part, it is not throwing that error. Can you please let me know where am I missing, am I making something wrong, is it related to Line 26 as in the message.
WITH CTE AS ( SELECT FILTER.GroupKey, FILTER.ClassScheduleId, SUM(SlotCount) AS SlotCount FROM #SlotInformation INFO INNER JOIN #Base FILTER ON FILTER.ClassScheduleId = INFO.ClassScheduleId AND ( @Level = 'Class' OR FILTER.UseInAggs = 1 ) WHERE SlotPlanTypeId IN (@SLOTPLAN\_ECEAP, @SLOTPLAN\_ECEAPSPED) GROUP BY FILTER.GroupKey, FILTER.ClassScheduleId ) INSERT INTO #Results (GroupKey, Identifier, Name, Value) SELECT WEEK.GroupKey, 'NIEER' AS Identifier, 'Number of ECEAP slots in ECEAP classes meeting 8 or more hours per day' AS Name, SUM(CASE WHEN WEEK.AverageHoursPerDay >= 8 THEN CTE.SlotCount ELSE 0 END) AS Value FROM #WeeklyOverview WEEK INNER JOIN CTE ON CTE.GroupKey = WEEK.GroupKey AND CTE.ClassScheduleId = WEEK.ClassScheduleId GROUP BY WEEK.GroupKey UNION ALL SELECT WEEK.GroupKey, 'NIEER' AS Identifier, 'Number of ECEAP slots in ECEAP classes meeting at least 4 hours but fewer than 8 hours per day' AS Name, SUM(CASE WHEN WEEK.AverageHoursPerDay >= 4 AND WEEK.AverageHoursPerDay < 8 THEN CTE.SlotCount ELSE 0 END) AS Value FROM #WeeklyOverview WEEK INNER JOIN CTE ON CTE.GroupKey = WEEK.GroupKey AND CTE.ClassScheduleId = WEEK.ClassScheduleId GROUP BY WEEK.GroupKey UNION ALL SELECT WEEK.GroupKey, 'NIEER' AS Identifier, 'Number of ECEAP slots in ECEAP classes meeting fewer than 4 hours per day' AS Name, SUM(CASE WHEN WEEK.AverageHoursPerDay < 4 THEN CTE.SlotCount ELSE 0 END) AS Value FROM #WeeklyOverview WEEK INNER JOIN CTE ON CTE.GroupKey = WEEK.GroupKey AND CTE.ClassScheduleId = WEEK.ClassScheduleId GROUP BY WEEK.GroupKey;
Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."