SQL - Delete Duplicate Records
Option 1:
WITH CTE AS(
SELECT [col1], [col2], [col3], [col4], [col5], [col6], [col7],
RN = ROW_NUMBER()OVER(PARTITION BY [col1], [col2] ORDER BY [col1], [col2])
FROM dbo.Table1
)
DELETE FROM CTE WHERE RN > 1
Option 2:
DELETE FROM dbo.TABLE WHERE AUTOID NOT IN (SELECT MIN(AUTOID)
FROM dbo.TABLE GROUP BY Col1, Col2)
Option 3:
SET ROWCOUNT 1
DELETE FROM dbo.duplicateTest WHERE ID = 1
SET ROWCOUNT 0
Option 4:
DELETE TOP(1) FROM dbo.duplicateTest WHERE ID = 1