fnNestedTargetedContentParts

Return

Return Type
table

Parameters

Parameter Parameter Type Mode Description
@SiteContentID int IN

Definition

Copy


            create function dbo.fnNestedTargetedContentParts(@SiteContentID int)
            returns @results table (id int) as begin
                declare toplevel cursor local fast_forward for
                    select 
                        sc.ID 
                    from 
                        dbo.TargetedContentPart tc
                        inner join dbo.TargetedContentChecks tcc on tcc.TargetedPartID = tc.ID
                        inner join dbo.SiteContent sc on sc.id=tcc.ContentID
                    where 
                        tc.SiteContentID = @SiteContentID 
                        and sc.ContentTypesID = 66;

                open toplevel;

                declare @id int;
                fetch next from toplevel into @id;
                while @@FETCH_STATUS = 0 begin
                    insert into @results (id) values (@id);
                    insert into @results
                        select id from dbo.fnNestedTargetedContentParts(@id)
                    fetch next from toplevel into @id;
                end

                close toplevel;
                deallocate toplevel;

                return;
            end