please see the query.
i want to develop a query in which when i give an id
i need to get all the names recursively. for example
when i give 3 i should get the names Customer,setup and Admin
i need to get it without using temporarytable and cursors.
Thanks in advance for your help.
DECLARE @tblPagePath TABLE
(id int,
name varchar(100),
pid int);
INSERT INTO @tblPagePath
( id, name, pid )
VALUES ( 1, -- id - int
'Admin', -- name - varchar(100)
null -- pid - int
)
INSERT INTO @tblPagePath
( id, name, pid )
VALUES ( 2, -- id - int
'Setup', -- name - varchar(100)
1 -- pid - int
)
INSERT INTO @tblPagePath
( id, name, pid )
VALUES ( 3, -- id - int
'Customer', -- name - varchar(100)
2 -- pid - int
);
SELECT *
FROM @tblPagePath
1 Answer