Menu Close

TSQL – Find Duplicate Records from a Table

SELECT ID

FROM yourTable

GROUP BY ID

HAVING (COUNT(ID) > 1)

In SQL 2005+ you can do the following and get all of the columns:

SELECT *
, ROW_NUMBER() OVER (PARTITION BY col1, col2, col3 ORDER BY (SELECT 0)) AS DuplicateRowNumber

FROM yourTable