Skip to content

Instantly share code, notes, and snippets.

@jacobhackl
Created August 24, 2015 18:04
Show Gist options
  • Save jacobhackl/7e59719adb4128ef831e to your computer and use it in GitHub Desktop.
Save jacobhackl/7e59719adb4128ef831e to your computer and use it in GitHub Desktop.
SQL delete for duplicates using WITH
;WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3
ORDER BY ( SELECT 0)) RN
FROM #MyTable)
DELETE FROM cte
WHERE RN > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment