Created
August 24, 2015 18:04
-
-
Save jacobhackl/7e59719adb4128ef831e to your computer and use it in GitHub Desktop.
SQL delete for duplicates using WITH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;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