Category Archives: T-SQL

Easily find duplicate rows using SQL Server 2005+

2_bgFinding duplicate rows in a table can be done very simply by using Common Table Expressions knows as CTE’s along with the SQL Server built-in function ROW_Number() with the <PARTITION BY> and <ORDER BY> arguments found in SQL Server 2005 or later. In the sample below I’m looking for products that exist in the Products table more than once where the ProductName, Quantity, and Price are the same.

Read more