Sorry..if my requirement is not clear...It is something like this
CREATE PROCEDURE pr_GetAllChildrenWithParentList
(@input Varchar(8000),
@Result Varchar(8000) OUTPUT )
.....
When @input=1,3
@Result=1,2,3,4,5,6,7,8
When @input=2,7
@Result=2,5,6,7,8
Its like traversing the tree till leaf node.Hope it...