0

the way to return the IDs after while loop is to create table variable to store them in process
declare @parents table
(
LVL int primary key identity(1,1), -- [optional] level in hierarchy
ParentID int
)
DECLARE @ParentId INT;
SET @ParentId = 7;
WHILE(@ParentId > 0)
BEGIN
SELECT @ParentId...