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)
 Possible recursion solution

Author  Topic 

natureman
Starting Member

3 Posts

Posted - 2006-03-10 : 09:49:02
Hi everyone! I have a question. My data looks like this:

name id referer
-------------------------
Tom 1 0
Becky 2 1
Jules 3 0
Ted 4 2
Holmes 5 2
Stacy 6 4

The id is asssigned to everyone individually, but the referer column is the id of the person that refered them, as you can see this can go infinite levels deep. I want to pull out each levels members and how many people are under them no matter what level they are at. I might be making this more complex than it should be, but it seems like recursion might be on order. This is on a SQL Server 2005 box, fyi.

Thanks for any help anyone can offer!

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-03-10 : 09:53:23
funny, I just posted a response to a similar question.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=63042

couple of article links:
http://www.sqlteam.com/item.asp?ItemID=8866
http://www.sqlteam.com/item.asp?ItemID=692

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -