title: Output Inserted.Id AND another field
body: <p>I have the following query:</p>
  
  <pre><code>DECLARE @OutProduct TABLE 
  (
      ProductID INT,
      BulkProductId INT
  )
  
  INSERT INTO dbo.Products 
          ( EanCode , 
            ChangedDateTime , 
            ChangedById , 
            Deleted  
          ) 
  OUTPUT INSERTED.ID, BulkProducts.Id INTO @OutProduct (ProductID, BulkProductId)
  SELECT  EanCode , 
          GETDATE(), 
          GETDATE(),
          0 
  FROM dbo.BulkProducts 
  WHERE ProductId is NULL
  </code></pre>
  
  <p>Assuming <code>Products.Id</code> &amp; <code>BulkProducts.Id</code> are auto-incrementing identity columns:</p>
  
  <p>What I'm trying to achieve:</p>
  
  <p><code>@OutProduct</code> temp table contains tuples made up of the just-inserted <code>Products.Id</code> and the Id of the row in <code>BulkProducts</code>.</p>
  
  <p>What I've stumbled upon: <code>BulkProducts.Id</code> cannot be used in the <code>OUTPUT INSERTED.ID, BulkProducts.Id INTO</code> statement, as it's not valid syntax.</p>
  
  <p>How can I solve this?</p>
  
  <p>EDIT: I'm using SQL Server 2012.</p>