Wednesday, December 19, 2012

Count Duplicate Records in Sql Server


Following query demonstrate how to get duplicate records count in a sql server table. It uses GROUP BY, HAVING and ORDER BY clauses and order the result in descending order.

SELECT MyColumn, COUNT(*) RecordCount
FROM tblTemp
GROUP BY MyColumn
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC

No comments:
Write comments
Recommended Posts × +