Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Pull child data alongwith parent data

Author  Topic 

KDesai
Starting Member

4 Posts

Posted - 2010-05-25 : 07:16:32
Hi, I have a parent-child relationship as under:

1 Node1 0
2 Child1_1 1
3 Child2_1 1
4 Node2 0
5 Child1_2 4
6 Child2_2 4
7 Child3_2 4
8 Node3 0
9 Child1_3 8.

Now I need to pull down the data from the database such that I can get the root node and the first three child columns in the output. In the above case the output should be like as under:

1 Node1 Child1_1 Child2_1 Null
2 Node2 Child1_2 Child2_2 Child3_2
3 Node3 Child1_3 Null Null

can anyone please help me in getting the proper SQL.

Regards,
Kunal
   

- Advertisement -