CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • The MERGE statement attempted to UPDATE or DELETE the same row more than once.

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    7291
  • Date Created
    Monday, February 2, 2026
  • This Article Has been Viewed
    0 times
  • Short Desc
    The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row.
  • Details
    When updating data across multiple tables, you might encounter this error if there are duplicate entries.

     

    The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.
  • Recreate Issue
    Scenario #1:
    This error will happen if you have a SQL Script that joins tables together based on either a Number or Word(s), in which the tables have multiple instances of the value, when they are only supposed to have one instance.
  • Resolve Issue
    Scenario #1:
    Run the following Script on each table to identify all duplicate values. Then run an update Script to correct the entries, and a delete Script to remove all dead entries ONLY after you have updated the original value with the duplicate values' content.

    -- To find duplicate values in a table.
    SELECT MemberName,COUNT(*)
    FROM Members
    GROUP BY MemberName
    HAVING COUNT(*) > 1


    Example of records found.
    126 Darrell_Roberts
    533 Darrell_Roberts

    In the live data example above. We checked and found that record 126 contains all the data, while record 533 contains only a single record.
    We then updated the 126 to retrieve the 533 value across all relevant tables.
    In this example, we are only showing one table to update and two tables to delete from.

    -- To update the values

    Update AnotherTable set BMID = 126 where BMID = 533



    Delete from Members where BMID = 533
    Delete from AnotherTable where BMID = 533