deleting the duplicate records from SQL Server table

 To delete the duplicate records(same records in one more time) from SQL Server Data base table,use this query.


SET ROWCOUNT 1

DELETE yourtable

FROM yourtable a

WHERE (SELECT COUNT(*) FROM yourtable b WHERE b.fname =

a.fname AND b.lname = a.lname) > 1

WHILE @@rowcount > 0

  DELETE yourtable

  FROM yourtable a

  WHERE (SELECT COUNT(*) FROM yourtable b WHERE b.fname =

a.fname AND b. lname = a. lname) > 1

SET ROWCOUNT 0