Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Hierarchical order by TSQL

$
0
0
Dear Sircreate table Hierarchy(ParentID int,ChildID int)goinsert into Hierarchy values (101,1),(1,6),(101,2),(2,4),(2,5),(5,6),(5,7),(101,3),(3,5)Please refer the Hierarchical order Diagram in order to understand how this hierarchy order constructed.we are focusing on filtering the parent ID.when we pass the parameter 101 , output should display as follows from the Hierarchy table.101/1/6101/2/4101/2/5/6101/2/5/7101/3/5/6101/3/5/7For 1 sql server output as follows1/6For 2 sql server output as follows2/42/5/62/5/7For 3 sql server output as follows3/5/63/5/7For 5 SQL Server output as follows5/65/7

Viewing all articles
Browse latest Browse all 3145

Trending Articles