SQL Server - How to Delete Duplicate Data?

 




Following the Sql Query below:

WITH DuplicateRows AS (

    SELECT *,

           ROW_NUMBER() OVER (PARTITION BY Column1, Column2, Column3, -- Add all relevant columns

                              [DateColumn] -- The date column here should be the one where '2024-06-21' is stored

                             ORDER BY (SELECT NULL)) AS RowNum

    FROM FCT_LOAN

    WHERE [DateColumn] = '2024-06-21'

)

DELETE FROM DuplicateRows

WHERE RowNum > 1;

Post a Comment

Previous Post Next Post