0

我在存储在 SQL Server 2008 中的表中有一个列,其中包含一些文档的完整路径。

我需要将路径转换为父子层次结构,如下所示。我需要这种结构,因为它是我使用它的第三方软件所必需的。

这是如何做到最优雅的?

从:

root/Dir1/Dir11/Dir3/Docname1.txt
root/Dir1/Dir12/Dir3/Docname2.txt
root/Dir1/Dir11/Docname3.txt
root/Dir1/Dir11/Dir31/Docname4.txt

至:

[Value]                 [Parent]
Docname1.txt            root/Dir1/Dir11/Dir3    
root/Dir1/Dir11/Dir3    root/Dir1/Dir11
root/Dir1/Dir11         root/Dir1
root/Dir1               root

Docname2.txt            root/Dir1/Dir12/Dir3
root/Dir1/Dir12/Dir3    root/Dir1/Dir12
root/Dir1/Dir12         root/Dir1
root/Dir1               root

Docname3.txt            root/Dir1/Dir11
root/Dir1/Dir11         root/Dir1
root/Dir1               root

Docname4.txt            root/Dir1/Dir11/Dir31
root/Dir1/Dir11/Dir31   root/Dir1/Dir11
root/Dir1/Dir11         root/Dir1
root/Dir1               root
4

1 回答 1

0

来自另一个网站的用户的回答:

http://ask.sqlservercentral.com/questions/100704/how-to-create-a-parent-child-hierarchy-from-full-p.html#answer-100739

于 2013-03-28T12:15:59.830 回答