First time posting on this forum, so please go easy on me.I have a recursive stored procedure that is responsible for building a bread crumb for an individual category id.CREATE PROCEDURE [dbo].[ctg_getCategoryBreadCrumb] ( @dept_id INT, @returnValue VARCHAR(1000) OUTPUT)AS DECLARE @rec_parent_id INT DECLARE @rec_dept_id INT DECLARE catCursor CURSOR LOCAL FAST_FORWARD FOR SELECT parent_id, dept_id FROM cablestogo_dept WHERE dept_id = @dept_id OPEN catCursor FETCH NEXT FROM catCursor INTO @rec_parent_id, @rec_dept_id CLOSE catCursor DEALLOCATE catCursor IF(@rec_parent_id = 0) set @returnValue = (SELECT dept_name FROM cablestogo_dept WHERE dept_id = @dept_id) ELSE BEGIN EXEC ctg_getCategoryBreadCrumb @rec_parent_id, @returnValue OUTPUT IF(@returnValue <> '') set @returnValue = @returnValue + ' > ' + (SELECT dept_name FROM cablestogo_dept where dept_id = @dept_id) ELSE set @returnValue = (SELECT dept_name FROM cablestogo_dept where dept_id = @dept_id) END RETURNGO
I also have created a stored procedure that will build breadcrumbs for all products. Products are related to category ids, so one product can have multiple breadcrumbs.CREATE PROCEDURE [dbo].[ctg_UpdateFroogleFeedBreadCrumb] AS DECLARE @curr_sku INT DECLARE @curr_dept_id INT DECLARE @return_value VARCHAR(1000) DECLARE @i INT SET @i = 0 DECLARE ffCursor CURSOR LOCAL FAST_FORWARD FOR SELECT TOP 100 ff.sku, cdp.dept_id FROM froogleFeed1 ff INNER JOIN cablestogo_dept_prod cdp ON ff.sku = cdp.sku INNER JOIN cablestogo_dept cd ON cdp.dept_id = cd.dept_id WHERE cd.redirect IS NULL ORDER BY ff.sku ASC OPEN ffCursor FETCH NEXT FROM ffCursor INTO @curr_sku, @curr_dept_id WHILE @@FETCH_STATUS = 0 BEGIN EXEC ctg_getCategoryBreadCrumb @curr_dept_id, @return_value OUTPUT PRINT @return_value FETCH NEXT FROM ffCursor INTO @curr_sku, @curr_dept_id SET @return_value = '' END Print @i CLOSE ffCursor DEALLOCATE ffCursorGO
There are 8583 records that I need to build breadcrumbs for. This works on small data sets, but when I attempt to run this against large amounts of data I get this error. Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).Any ideas on how to correct this issue?