Blog Details

How to remove duplicate row without primary column in SQL table?

Remove duplicate row without primary column in SQL Server


WITH CTE AS (
    SELECT 
        *, 
        ROW_NUMBER() OVER (PARTITION BY Column1, Column2, Column3 ORDER BY (SELECT NULL)) AS RowNum
    FROM YourTable
)
DELETE FROM CTE
WHERE RowNum > 1;

Post Comment

Your email address will not be published. Required fields are marked *