title: Merge with delete nested query not giving delete count
body: <p>I am trying merge with delete in that I want to take count of records getting deleted.</p>
  
  <p>I have following snippet</p>
  
  <pre><code>MERGE @DuplicateCurrencyData DD 
  USING (SELECT PP.PAYMENTB_ID,PP.PPID,PP.BID FROM ProfileTable PP) tempTable
              ON DD.PPID = tempTable.PPID
  
     WHEN MATCHED THEN
          UPDATE SET DD.PBID = tempTable.PAYMENTB_ID 
  
  OUTPUT
      $action, Updated.PBID 'Updated' INTO #MergeCountP;
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Msg 4104, Level 16, State 1, Line 122<br>
    The multi-part identifier "Updated.PBID" could not be bound.</p>
  </blockquote>
  
  <p>If I not take count <code>Merge</code> statement works fine. I am unable to understand how to get rid of it</p>