Deleting duplicates in SQL Server before adding a Unique Index
Quick reference on how to remove only the duplicate rows when attempting to add a unique index: WITH custom AS ( SELECT [projectId], [zoneId], [type], [name], RN = ROW_NUMBER() OVER (PARTITION BY [projectId], [zoneId], [type], [name] ORDER BY [projectId]) FROM [mydata].[dbo].[Properties] ) DELETE FROM custom WHERE RN > 1