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
 SSIS and Import/Export (2005)
 parent child problem in sql

Author  Topic 

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-07-01 : 09:30:51
I want to find all the child of a node in a tree . A child can have multiple parent i.e 2 can be place under multiple parent . The folling is the data:

ParentID ChildID
-------------------------
10 8
8 6
8 7
7 2
7 5
5 1
5 2
6 2

child of parent if input 10
8
7
6
2
2
5
1
(2) can be neglected

input 7
2
5
1
(2) can be neglected

input 8
7
2
5
(2) can be neglected


Plz help we to write the sql statements

Thanks



nr
SQLTeam MVY

12543 Posts

Posted - 2007-07-01 : 12:12:26
Have a look at CTEs - there's an example of tranversing a hierarchy in bol.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-07-01 : 12:39:50
nr,
what is CTEs? So I may look over there.
Thanks
ss
Go to Top of Page
   

- Advertisement -