Duplicates: How to find duplicate field values
Date Revised: August 14 2009
Shows how to use t-sql to count the number of duplicate values in a field. There is another example
here which shows the same, only using a cursor.
-- Database to use
USE DatabaseName;
-- The trick is to use GROUP BY - HAVING a count greater than 1
SELECT fieldName,
COUNT(fieldName) AS NumOccurrences
FROM dbo.TableName
GROUP BY fieldName
HAVING ( COUNT(fieldName) > 1 );