title: SQL Server: Multiple Output Clauses
body: <p>I have two tables, <code>Table_1</code> and <code>Table_2</code>. </p>
  
  <p><code>Table_1</code> has columns <code>PK</code> (autoincrementing <code>int</code>) and <code>Value</code> (<code>nchar(10)</code>). </p>
  
  <p><code>Table_2</code> has <code>FK</code> (<code>int</code>), <code>Key</code> (<code>nchar(10)</code>) and <code>Value</code> (<code>nchar(10)</code>). </p>
  
  <p>That is to say, <code>Table_1</code> is a table of data and <code>Table_2</code> is a key-value store where one row in <code>Table_1</code> may correspond to 0, 1 or more keys and values in <code>Table_2</code>.</p>
  
  <p>I'd like to write code that programmatically builds up a query that inserts one row into <code>Table_1</code> and a variable number of rows into <code>Table_2</code> using the primary key from <code>Table_1</code>.</p>
  
  <p>I can do it easy with one row:</p>
  
  <pre><code>INSERT INTO Table_1 ([Value])
  OUTPUT INSERTED.PK, 'Test1Key', 'Test1Val' INTO Table_2 (FK, [Key], [Value])
  VALUES ('Test')
  </code></pre>
  
  <p>But SQL doesn't seem to like the idea of having multiple rows. This fails:</p>
  
  <pre><code>INSERT INTO Table_1 ([Value])
  OUTPUT INSERTED.PK, 'Test1Key', 'Test1Val' INTO Table_2 (FK, [Key], [Value])
  OUTPUT INSERTED.PK, 'Test2Key', 'Test2Val' INTO Table_2 (FK, [Key], [Value])
  OUTPUT INSERTED.PK, 'Test3Key', 'Test3Val' INTO Table_2 (FK, [Key], [Value])
  VALUES ('Test')
  </code></pre>
  
  <p>Is there any way to make this work?</p>