Recursive same-table query in SQL Server 2008

后端 未结 4 1568
谎友^
谎友^ 2020-12-01 02:28

I have the following table in a SQL Server 2008 database:

Id  Name       ParentFolder
--  ----       ------------
1   Europe     NULL
2   Asia       NULL
3           


        
4条回答
  •  无人及你
    2020-12-01 03:10

    I'm not sure if this will work in your case, but in this example http://www.pure-performance.com/2009/03/managing-hierarchical-data-in-sql/ there is something about using an extra column, called lineage.

    I have used this method with success.

提交回复
热议问题