Skip to content

Instantly share code, notes, and snippets.

@halityurttas
Created January 3, 2021 14:28
Show Gist options
  • Save halityurttas/92d0ee471355e11d84ef19c0be2796d4 to your computer and use it in GitHub Desktop.
Save halityurttas/92d0ee471355e11d84ef19c0be2796d4 to your computer and use it in GitHub Desktop.
Remove duplicate sql (for example nop commerce specification attributes)
WITH duplicates AS (
SELECT
*,
ROW_NUMBER() OVER (
PARTITION BY SpecificationAttributeId, Name
ORDER BY SpecificationAttributeId, Name
) RN
FROM
[nopdb].[dbo].[SpecificationAttributeOption]
)
DELETE FROM duplicates WHERE RN > 1;
--SELECT * FROM duplicates WHERE RN = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment