There are many ways of detecting duplicate data in your tables. One of the quick and easiest methods I have found is to use the below syntax.
It will return a list of duplicate entries by the field that you’ve chosen and the number of duplications. This then allows you to use that list in a subsequent query to return all of the data within the duplicate row. From there you can then make a decision about what you want to do with the duplicate data.
1 2 3 4 5 |
SELECT EmployeeID, COUNT(*) FROM #testTable GROUP BY EmployeeID HAVING COUNT(*) > 1; GO |
Leave a Comment