title: Data structures available in SQL Server 2008
body: <p>I am creating my first stored procedure in SQL Server 2008 and the problem I am attempting to solve needs some sort of data structure that can hold a string associated to multiple other strings, either a hash, or tree of some sort. However I cannot seem to find any examples of this online. Is there a way to use maps or trees in sql stored procedures, or is it assumed that this sort of heavy lifting by done outside in the code?</p>
  
  <p>To be more specific on the problem, it deals with organizational charts. I have a query that can produce every employee and their immeadiate supervisor, but the output that is wanted by the rest of the team is a result set that has all people reporting below a given individual, but with an extra column for their supervisor below the given person. It might be easier to see than talk about.</p>
  
  <p>For Example:</p>
  
  <pre><code>Jim and Billy report to Bob, Paul and April report to Kurt 
  Kurt and Ed report to Tim, Laurie and Bob report to George
  George reports to Maggie
  Maggie and Tim report to Jessica
  </code></pre>
  
  <p>With an input of Jessica, the information I need printed out would look like:</p>
  
  <pre><code>Jim reports to Maggie
  Billy reports to Maggie
  Paul reports to Tim
  April reports to Tim
  Kurt reports to Tim
  Ed reports to Tim
  Laurie reports to Maggie
  Bob reports to Maggie
  George reports to Maggie
  Tim reports to Jessica
  Maggie reports to Jessica
  </code></pre>
  
  <p>The real problem so far has been when running through the loop, I am going down one level at a time and finding everyone under the new records. This works fine if I just want the immeadiate supervisor, but in order to get that jump up to one level below the input I am needed to store the information some where, and I don't know what kind of structures would be supported within SQL for this task.</p>