title: SQL Server : splitting a row into multiple rows from OUTPUT clause
body: <p>I am trying to get a query that can help me achieve something similar to the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/XzIcM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XzIcM.png" alt="Output result set"></a></p>
  
  <p>The first table is the result of a SQL <code>OUTPUT</code> clause (both inserted and deleted). I would like to split these results into a new table (like the second one in the above image). So I want to have one row depicting the inserted records and the second row depicting the deleted records.</p>
  
  <p>This is how my sample data was created:</p>
  
  <pre><code>select 
      inserted_ID = 1,
      inserted_name = 'Brian',
      inserted_phone = '123-456-7890',
      operation_type1 = 'inserted',
      deleted_id = 2,
      deleted_name = 'James',
      deleted_phone = '222-222-2222',
      operation_type2 = 'Deleted'
  into 
      #tbltest
  </code></pre>