The Business Intelligence Blog

March 27, 2010

How to find duplicate rows in a table in SQL Server

Filed under: SQL Server Database — Tags: , — Shahfaisal @ 1:55 pm

To demonstrate this, I have a table with 2 duplicate rows as shown in the figure below:

And here is the query you can use to find out duplicate rows:

SELECT ProductID, ProductName, ProductNumber, Cost, NumberOfDuplicateRows=count(*)
FROM dbo.Product
GROUP BY ProductID, ProductName, ProductNumber,Cost
HAVING count(*) > 1



Create a free website or blog at WordPress.com.