Skip to content

Instantly share code, notes, and snippets.

@neilcamm
Created December 15, 2012 18:17
Show Gist options
  • Select an option

  • Save neilcamm/4297794 to your computer and use it in GitHub Desktop.

Select an option

Save neilcamm/4297794 to your computer and use it in GitHub Desktop.
Delete duplicate rows in SQL Server
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