title: Creating a composite foreign key in SQL Server 2008
body: <p>I have two tables that I'd like to create a foreign key for.</p>
  
  <p><strong>Primary Table</strong></p>
  
  <pre><code>PK - Key1 - varchar(20)
  PK - Key2 - date
  </code></pre>
  
  <p><strong>Secondary Table</strong></p>
  
  <pre><code>PK - AutoID
  FK - Key1 - varchar(20)
  FK - Key2 - date
  </code></pre>
  
  <p>When I try to create the relationship between the primary and secondary table, I keep getting the message </p>
  
  <blockquote>
    <p>The columns in the Primary Table do not match a primary key or unique
    constraint.</p>
  </blockquote>
  
  <p>There can be many records in the secondary table with the same Key1 and Key2 so we made the primary key an auto created number.</p>
  
  <p>Any thoughts on how I can set up the foreign key relationship between these two tables?</p>