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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-09-05 : 09:39:42
|
| Richard writes "For a client of mine, I need to come up with a way to retrieve the downline of any one of their distributors in the database. Each distributors record has a unique ID, an "L" or "R" for which side of their sponsor they are on, and a Sponsor ID.I currently have a program (vb) that is traversing the tree using a recursive function, but this table now has over 8000 distributors in it, and in some cases takes far too long to run to be practical.I thought about writing a recursive stored procedure and populating a temporary table, but I have no guarantee that the distributor won't have more than 32 (or whatever the max recursive limit on SQL Server 2000 is) levels in his/her downline.Running this takes too long from ASP and VB, which are the languages I am forced to write the client app in, and so I am trying to find a way to do it on the server, as efficiently as possible. The information needs to be up to the minute, so I can't just run a batch every night.The only way I can think of to do this is using iteration instead of recursion, which I know is possible, but I can't figure out how to do it.Any ideas would be greatly appreciated!" |
|
|
|
|
|