Skip to content

Instantly share code, notes, and snippets.

@Saanch
Created April 9, 2015 01:29
Show Gist options
  • Save Saanch/c4f93d054c34978d538a to your computer and use it in GitHub Desktop.
Save Saanch/c4f93d054c34978d538a to your computer and use it in GitHub Desktop.
MSSQL Query to delete duplicate rows from a TABLE leaving the first occurance
DELETE FROM [tableName] WHERE [UniqueId] NOT IN
(SELECT Min([UniqueId]) FROM [tableName] GROUP BY [fieldName])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment