Last active
January 20, 2016 14:24
-
-
Save everettcaleb/a67891941b2b60c8f2dc to your computer and use it in GitHub Desktop.
Finds duplicate records in a table
This file contains 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 | |
[Field], | |
COUNT(1) AS [Count] | |
FROM [dbo].[Table] | |
GROUP BY [Field] | |
) | |
SELECT [T].[Field] | |
FROM [Table] [T] | |
INNER JOIN [CTE] ON [T].[Field] = [CTE].[Field] | |
WHERE [CTE].[Count] > 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment