title: Creating a hierarical tree and retuning as xml using SQL Server stored procedure
body: <p>I have a following table.</p>
  
  <pre><code>CategoryId        Category_name        ParentId
  1                 Products                0
  2                 Property                0
  3                 Electronics             1
  4                 Computer                3
  5                 Camera                  3
  6                 Books                   1
  </code></pre>
  
  <p>How can I return a hierarchical xml from this, using a SQL Server CTE ?</p>
  
  <p>thanks in advance.</p>