Created
December 15, 2012 18:17
-
-
Save neilcamm/4297794 to your computer and use it in GitHub Desktop.
Delete duplicate rows in SQL Server
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
| SET NOCOUNT ON | |
| SET ROWCOUNT 1 | |
| WHILE 1 = 1 | |
| BEGIN | |
| DELETE FROM major | |
| WHERE name IN (SELECT name | |
| FROM Major | |
| GROUP BY name | |
| HAVING COUNT(*) > 1) | |
| IF @@Rowcount = 0 | |
| BREAK ; | |
| END | |
| SET ROWCOUNT 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment