Mahesh .NET Blog
Friday, May 2, 2008
Duplicate Records Count
SELECT empname,COUNT(empname) FROM test2 GROUP BY empname
HAVING COUNT(empname) > 1
SELECT COUNT(*),empname FROM test2 GROUP BY empname HAVING COUNT(*)>1
Deleting Duplicate Records in the Table
Table Name : Test2
Fields : empid,empname
Query to Delete the Duplicate values and keeping one value in the table.
set rowcount 1
select 1
while @@rowcount > 0
delete test2
where 1 < (select count(*) from test2 a2 where test2.empid = a2.empid)
set rowcount 0
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)