title: Foreign key linked with primary key in same table
body: <p>I have a table <code>Categories</code> with columns <code>Id, ParentId</code> (for "subcategories" whom can have any level of nesting) and some other. Using SQL Server 2012 I can't make foreign key in same table, <code>FK_Categories_Categories</code> (<code>Id -&gt; ParentId</code>). </p>
  
  <p>Error message is</p>
  
  <blockquote>
    <p>'Categories' table<br>
    - Unable to create relationship 'FK_Categories_Categories'. The ALTER TABLE statement conflicted with the FOREIGN KEY SAME TABLE constraint "FK_Categories_Categories". The conflict occurred in database "pokupaykadb", table "dbo.Categories", column 'Id'.</p>
  </blockquote>
  
  <p>That needs for cascade deletion of subcategories. What solution can be? It's desirable to be a some property, like cascade deletion from another table by foreign key</p>
  
  <p><a href="http://i.stack.imgur.com/kXiMS.png" rel="nofollow">http://i.stack.imgur.com/kXiMS.png</a></p>