jeudi 28 mai 2015

sql query to get all child nodes of a parent in sqlserver 2005

In sqlserver 2005 how can i find all directly related and indirectly related child of a parent.

For eg 27 is a parent.31 is a direct child of 27.But 32 is the child of 31.Since 32 is the child of 31 ,and 31 is the child of 27, both 31 and 32 is the child of 27.Also 27 itself is the child of 27.

The result must be comma seperated,with coloum names parent and Children. The result must comes as follows.

27(parent) 27,31,32... (childs)

Thanks

Aucun commentaire:

Enregistrer un commentaire