larsbloch
10/5/2017 - 5:55 PM

Remove duplicates, SQL

Remove duplicates, SQL

WITH a as
(
SELECT [InsertAtributeHere], ROW_NUMBER() OVER(PARTITION by [InsertAtributeHere] ORDER BY [InsertAtributeHere]) 
AS duplicateRecCount
FROM dbo.table
)

Select * from a
WHERE a.duplicateRecCount > 1

--Delete Duplicate Records
--DELETE FROM a
--WHERE a.duplicateRecCount > 1