Finding Duplicate Row Values with SQL

Every once in a while I have the need to find duplicate row values in a SQL table. I seem to forget how to do it each time since its not something I have a use for every day, so I thought I’d record it here and share. The solution I found was here:

http://www.petefreitag.com/item/169.cfm

Basically, the SQL code is as follows:

SELECT ColumnName, COUNT(ColumnName) AS ColumnNameCount
	FROM MyTable
GROUP BY ColumnName
HAVING (COUNT(ColumnName) > 1)

That’s it, enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.