title: Foreign key referencing a 2 columns primary key in SQL Server
body: <p>This question is pretty much similar to <a href="https://stackoverflow.com/questions/953035/multiple-column-foreign-key-in-mysql">this one</a>, but for SQL Server 2005 :</p>
  
  <p>I have 2 tables in my database:</p>
  
  <pre><code>--'#' denotes the primary key
  [Libraries]
  #ID   #Application  Name
   1     MyApp        Title 1
   2     MyApp        Title 2
  
  
  [Content]
  #ID   Application  LibraryID  Content
   10    MyApp       1          xxx
   11    MyApp       1          yyy
  </code></pre>
  
  <p>(the database is obviously much more complex and having this double key makes sense)</p>
  
  <p>Each library is identified by its unique ID and Application name. I'm trying to ensure that each content is properly referencing an existing library.</p>
  
  <p>When creating the constraint (using the Wizard) as</p>
  
  <pre><code>Primary key table            Foreign key table
  [Libraries]                  [Content]
  ID                  ---&gt;     LibraryID
  Application         ---&gt;     Application
  </code></pre>
  
  <p>I have the following error: </p>
  
  <blockquote>
    <p>The columns in table 'Libraries' do
    not match an existing primary key or
    UNIQUE constraint</p>
  </blockquote>
  
  <p>Do you have any idea of what is going on? and if it's possible at all using SQL Server? (I can't modify the [Library] table at all)</p>
  
  <p>Thanks a lot for your help!</p>