How to detect duplicate rows in a SQL Server table? How to detect duplicate rows in a SQL Server table? sql-server sql-server

How to detect duplicate rows in a SQL Server table?


To show an example of what others have been describing:

SELECT    Col1, -- All of the columns you want to dedupe on    Col2, -- which is not neccesarily all of the columns    Col3, -- in the table    Col4,    Col5,    Col6,    Col7,    Col8,    Col9,    Col10FROM    MyTableGROUP BY    Col1,    Col2,    Col3,    Col4,    Col5,    Col6,    Col7,    Col8,    Col9,    Col10HAVING    COUNT(*) > 1


You can use group by on all columns and then count(*)>1


Try this

Select * From TableGroup By [List all fields in the Table here]Having Count(*) > 1