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 2005 Forums
 Transact-SQL (2005)
 Add a weighted column to a table...

Author  Topic 

Sanatan
Starting Member

19 Posts

Posted - 2010-04-21 : 16:19:08
I have a user table which also contains the managers of users and so on (the complete org hierarchy).

I want to be able to select the data from the table in a hierarchial manner so that I can get a complete hierarchy.

e.g. Manager_Level1
Manager_Level2
Manager_Level3
User1 User2 User3

I want to be able to retrieve the data in the order of Manager_Level1, Manager_Level2, Manager_Level3, User1, User2, User3 etc.

Thanks in advance.. Please let me know if you have any questions.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-04-21 : 16:21:05
More information(table structure, sample data and expected output) would help.

To being with, have a look at CTE. A similar example is illustrated.
http://msdn.microsoft.com/en-us/library/ms186243.aspx
Go to Top of Page
   

- Advertisement -