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 |
ahouse
Starting Member
27 Posts |
Posted - 2008-01-29 : 11:39:25
|
Good Morning - I am having trouble piecing together the following view in SQL Enterprise. Someone grace me with their genious. I have the following table called RUSER - The important columns are UserID, ManagerID, UserName, NameHere is some sample data to look at :UserID ManagerID UserName Name120 58 39 Erin97 120 80 Julie58 65 37 Steph136 120 28 ChrisThe UserID column is simply a count. The next user added gets the next number (primary key I believe) It works like this - Julie and Chris have manager ID of 120 so Erin is their manager. that makes Steph the manager of Erin. I need to somehow create a view so that Erin, Julie AND Chris all have a new field with Erins UserName(39) attached to it. I want to hardcode only certain managers to show up with their teams. I can do this fine when trying to find out who is on who's team based on the manager's ID by linking the tables RUSER and RUSER1 together joined on (WHERE userid = 39) join userID to managerID but the list doesn't include the manager then. Any ideas how to do this? I'm completely stuck! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-29 : 12:54:58
|
have a look at this:-http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm |
 |
|
ahouse
Starting Member
27 Posts |
Posted - 2008-01-29 : 16:06:42
|
quote: Originally posted by visakh16 have a look at this:-http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm
Thank you for the input. Recursion is an interesting way to go. I decided to just hard code a new table for now since there are only 100 or so users. Thanks again for the article. |
 |
|
|
|
|