>I need to model an Agent structure where an Agent reports to a superior who can report to a superior and so on ad infinitum.
>
>I have recently discovered the HierarchyID type in SQL Server and would like to know how exactly I need to create the table.
>
>I have an AgentPK field of type uniqueidentifier. Now I need the Hierarchy, do I just create a field like HieararchyPath type HierarchyID? I get the impression from what I have found on-line that the hierarchyid field holds the path of all superiors' primary keys, so is a uniqueidentifier appropriate to use as the table's Primary Key? Or does it not matter?
>
>Is using the hierarchyid the best way to do this, or do I go with the old ReportsTo field where I store the superior's Primary Key in this field?
(Copy and Paste) :-)))))))))))))
You should check Using hierarchyid Data Types (Database Engine) in BOL to see if it is appropriate type.
BTW If (and I see that you will) use SQL 2005 or 2008 you may use CTE (Common Table Expression) to get the Hierarchy.
But Naomi is the Master of CTEs :-)))))))))))))))))))))
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.