title: Inserting Data Using Table Value Parameter and Then Outputting Inserted Variables and Variables From the Table Value Parameter
body: <p>Consider the following table and table value parameter:</p>
  <pre><code>CREATE TABLE PersonTable
  (
     id INT IDENTITY(1,1),
     Name VARCHAR(50)
  )
  
  CREATE TYPE PersonTVP AS TABLE
  (
     Name VARCHAR(50),
     Hash INT
  )
  </code></pre>
  <p>I have created a procedure that inserts documents that are passed as the TVP parameter:</p>
  <pre><code>CREATE PROCEDURE PersonTableInsert
  (
     @People PersonTVP READONLY
  )
  AS BEGIN
  
  SET NOCOUNT ON;
  
  INSERT INTO PersonTable
  OUTPUT INSERTED.id, INSERTED.Name
  SELECT [Name] FROM @People;
  
  SET NOCOUNT OFF;
  
  END
  </code></pre>
  <p>Is it possible to also output the Hash variable from the TVP on the OUTPUT line? For example:</p>
  <pre><code>OUTPUT INSERTED.id, INSERTED.Name, @People.Hash
  </code></pre>
  <p>This would allow the application calling the procedure to capture the unique id as well as the Hash variable from the TVP.</p>
  <p>I hope this makes sense.</p>
  <p>Many thanks</p>