SQL Server - How to remove duplicate rows/records?

WITH T
AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY Col1) RN
FROM YourTable)

DELETE FROM T WHERE RN>1 -- delete duplicate rows

Comments