• SQL-Squid,

    You're correct in what you said the issue is that your source has duplicates, so based on the below you will always return multiple results, hence the MERGE statement returns that error.

    MERGE [AssetClassUDF] AS target

    USING [RawData_AssetClassUDF] AS source

    ON target.ASSETDETAIL_Id = source.ASSETDETAIL_Id

    AND target.ASSET_UDF_DESC = source.ASSET_UDF_DESC

    Unfortunatley with the MERGE as the error says you cant update/insert the same record twice... so you only have 2 options.

    1. use a GROUP BY in your MERGE so that way it will treat duplicates as One value & this should fix your problem (If this is what you want)

    or

    2. Clean the SOURCE so it doesn't contain duplicates.

    I personally don't like Option 2 - Cleaning the source file as this is how it gets delivered and always good reference point when you want to compare RAW -> STAGING -> LIVE.