Monday, November 7, 2011

FInding Duplicate Records In Database

Table Name: tblMasterUsers
Column Name: uname

here i wrote a query for finding duplicate records for uname column in tblMasterUsers

QUERY:
select * from tblMasterUsers where uname in
(select uname from tblMasterUsers group by uname having count(uname)>1)



Above query returns all dupicate values in a table. duplicate count must be greater then one. It Doesn't count any spelling mistake values.

example: erp is a duplicate record for erp
erps is a spelling mistake record for erp not a duplicate.

No comments:

Post a Comment