title: Foreign key constraint with some where clause in SQL Server
body: <p>I have two tables, one with columns <code>accountid, category, code, name, desc</code> and the other with columns <code>id, accountid, code, reason, desc, active</code>.</p>
  
  <p>Is there any way I can create a constraint such that <code>code</code> in the second table contains only values of <code>code</code> that are in first table with condition where category is <code>somevalue</code>?</p>