t-sql getting leaf nodes
Posted
by stackoverflowuser
on Stack Overflow
See other posts from Stack Overflow
or by stackoverflowuser
Published on 2010-05-18T19:11:21Z
Indexed on
2010/05/18
19:30 UTC
Read the original article
Hit count: 174
Based on following table (I have kept spaces between the rows for clarity)
Path
-----------
\node1\node2\node3
\node1\node2\node3\node5
\node1\node6\node3
\node1\node4\node3
\node1\node4\node3\node7
\node1\node4\node3\node8
\node1\node4\node3\node9
\node1\node4\node3\node9\node10
I want to get all the paths containing leaf node. So for instance, following will be considered leaf nodes for path \node1\node4\node3
\node1\node4\node3\node7
\node1\node4\node3\node8
\node1\node4\node3\node9\node10
The following will be the output:
Output
---------------------------
\node1\node2\node3\node5
\node1\node6\node3
\node1\node4\node3\node7
\node1\node4\node3\node8
\node1\node4\node3\node9\node10
Pls. suggest. Thanks.
© Stack Overflow or respective owner