mercredi 31 août 2016

Merge with delete nested query not giving delete count

I am trying merge with delete in that I want to take count of records getting deleted I have following snippet

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;

It gives me error

Msg 4104, Level 16, State 1, Line 122
The multi-part identifier "Updated.PBID" could not be bound.

If I not take count Merge statement works fine , I am unable to understand how take rid of it

Aucun commentaire:

Enregistrer un commentaire