Finding Duplicate Records in a Database Table
Posted by Dee Dutton on Fri, Aug 14, 2009 @ 10:13 AM
I often need to find duplicate records in a database table. The following SQL expressions (which work in SQL, Oracle or Access as well) will return a result set of duplicate records:
Simple:
select distinct employee from employees (nolock) group by employee having count(employee) > 1 order by employee |
Complex:
select employee, firstname, lastname, dob
from employees (nolock)
where employee in
(select employee from employees (nolock)
group by employee
having count(employee)>1)
order by employee