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 2000 Forums
 Transact-SQL (2000)
 Simple Hierarchical Query

Author  Topic 

adlo
Posting Yak Master

108 Posts

Posted - 2004-12-02 : 12:10:09
Group (Group_ID,Name,Parent_ID)
Member_Group (Group_ID,Member_ID)

I need a sp that gets a list of al the Member_ID's for a spesific group(@Group_ID) and all its child groups.

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-02 : 12:41:39
Some sample data would help, and what you're expected results should be...BUT

You're missing a column that shouws the relationships between id's



Brett

8-)
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-02 : 12:42:07
http://www.nigelrivett.net/RetrieveTreeHierarchy.html



==========================================
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

adlo
Posting Yak Master

108 Posts

Posted - 2004-12-03 : 06:05:56
Group Table

Group_ID Name Parent_ID
1 Action Groups 0
4 Music Teams 0
6 Leaders 0
7 Office 0
10 Youth 0
11 Kids 10
12 Teens 10
14 Tuesdays 1
15 Wednesday 1
17 Thursdays 1
18 Fridays 1
19 Morning 14
20 Afternoon 14
54 Youth Choir 4
55 Ladies Choir 4
56 Childrens choir 4
59 Office Staff 7

Member_Group
Member_ID Group_ID
100 54
101 15
102 15
103 18
104 19
105 19
106 20

Results must be
101
102
103
104
105
106

I am preferably looking for a non cursor and non temp table sp.
Go to Top of Page
   

- Advertisement -