I am creating multi level hierarchy in SQL Server. How can I create that?
This my table data-
ID DeptID ParentID FolderName
1 1 0 2
2 1 1 2.1
3 1 1 2.2
4 1 1 2.3
5 1 2 2.1.1
6 1 2 2.1.2
7 1 2 2.1.3
8 1 2 2.1.4
9 1 5 2.1.1.1
10 1 5 2.1.1.2
11 1 5 2.1.1.3
12 2 0 1
13 3 0 3
I want following result.
ID DeptID ParentID FolderName
1 1 0 2
2 1 1 2.1
5 1 2 2.1.1
9 1 5 2.1.1.1
10 1 5 2.1.1.2
11 1 5 2.1.1.3
6 1 2 2.1.2
7 1 2 2.1.3
8 1 2 2.1.4
3 1 1 2.2
4 1 1 2.3
12 2 0 1
13 3 0 3