• Try running these two statements at the same time:

    With Dups as

    (

    select *, row_number() over (partition by Product_Code order by Product_Code) as RowNum from #prod

    )

    Delete from Dups where rownum > 1;