In my MS SQL 2008 R2 database I have this table:
TABLE [Hierarchy]
[ParentCategoryId] [uniqueidentifier] NULL,
[ChildCategoryId] [uniqueidentifier] NOT NULL
I need to write a query that will generate all paths that lead to a given Node.
Lets say it I have the following tree:
A
-B
--C
-D
--C
Which would be stored as:
NULL | A
A | B
A | D
B | C
D | C
When asking for the Paths for C, I would like to get back two paths (written more or less like this):
A > B > C,
A > D > C
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…