User Tools

Site Tools


find_duplicate_rows_by_specific_columns

Find Duplicate Rows By Specific Columns

Consider a table, MyTable, with four columns: KeyCol, NameCol, IsActive, RowVersion. If you wanted to find all rows where NameCol and IsActive have the same values, you could do it as follows:

SELECT * FROM
 (SELECT NameCol, IsActive, COUNT(*) AS DupCount
 FROM MyTable
 GROUP BY NameCol,IsActive) AS ResultSet
WHERE ResultSet.DupCount > 1
find_duplicate_rows_by_specific_columns.txt · Last modified: 2018/12/31 18:38 by 127.0.0.1