Modifying a query to show navigation path |
 |
EXPERT RESPONSE FROM: Adam Machanic

|
 |
|


|
| > |
QUESTION POSED ON: 27 June 2006
I viewed your article on the Common Table Expression that will recursively query itself. How can I modify this query to show the navigation path down the tree to each node returned in the result set, in a different format? For example, if the data is:
ID ParentId
A null
B A
C A
D B
E C
I want the result from your query to be:
ID Level Path
A 1 A
B 2 A.B
C 2 A.C
D 3 A.B.D
E 3 A.B.C
|
|
To continue reading for free, register below or login
To read more you must become a member of SearchSQLServer.com
|
|
');
// -->

|
|
 |

 |
 |
Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
|
 |
 |
 |
|
 |
 |
 |
|
 |
|
 |