• Whether a MERGE performs an INSERT, UPDATE, or DELETE depends on the logic you have coded in the MATCHED clause.

    Based on the code you posted earlier, it hinges on this:

    ".. ON factd.METRICKEY = vwFactDeal.METRICKEY

    and factd.dealkey = vwFactDeal.dealkeyid .."

    Probably what's going on is that the MERGE statement is performing an UPDATE due to previously inserted keys, rather than performing the INSERT you anticipated.

    Also, the source of your MERGE is a view called vwFactDealMetricAmtPercentage for which we don't know the SELECT statement. Consider how the previous insertion of rows into the target table affects what rows are subsequently returned from this view.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho