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 2008 Forums
 Transact-SQL (2008)
 hierarchyid questio

Author  Topic 

evgeny
Starting Member

1 Post

Posted - 2011-04-28 : 17:21:50
hello gurus

I have a question.

I have requirement o develop some organization hierarchy modul
that alows next rules.
1.every employee have only one manager
2.no loops in the organization A->B->C->A

how can i use heirarchyid or this?


Evgeny.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-04-28 : 17:57:37
use a recursive cte (Common Table Expression).

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-04-28 : 18:19:17
You might want to do some research on Tree and Hierarchies in SQL. Joe Celko wrote a book on the subject and there are lots of articles around the web on the topic. A couple key phrase that might help your seach are "Nested Sets" and "Adjacency List Model".
Go to Top of Page
   

- Advertisement -