Forudsat ingen nuller, GRUPPER EFTER
de unikke kolonner og SELECT
DELETE FROM MyTable
LEFT OUTER JOIN (
SELECT MIN(RowId) as RowId, Col1, Col2, Col3
FROM MyTable
GROUP BY Col1, Col2, Col3
) as KeepRows ON
MyTable.RowId = KeepRows.RowId
WHERE
KeepRows.RowId IS NULL
Hvis du har en GUID i stedet for et heltal, kan du erstatte
MIN(RowId)
med
CONVERT(uniqueidentifier, MIN(CONVERT(char(36), MyGuidColumn)))