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 |
|
attackmonkey
Starting Member
19 Posts |
Posted - 2002-08-14 : 05:44:57
|
| I have a database table of users, which has the user's id, which is the primary key, several typical user details fields and the user id of the user that created the user account. Now I need to be able to list off all users that a user has created, as well as all the users that they have created as well (basically all users below them inthe chain). What would be the best way to pull this out as a single select list. I can do it using a recursive function in asp to sort all of teh users and display in a nice tree, but I also need to be able to just pull a complete list out as well, and I can't for the life of me figure out the best (or any) way of doing it.Any help greatly appreciated!:)Tim. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-14 : 05:50:45
|
| You have a tree on which a lot has ben written on this sitetry something likecreate table #a(id int)insert #a select @useridwhile @@rowcount > 0insert #a select distinct userid from tbl, #a where tbl.createduser = #a.userid and not exists (select * from #a where tbl.userID = #a.ID)select * from #adrop table #a==========================================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. |
 |
|
|
|
|
|