How to delete the rows which are duplicate (don’t delete both duplicate records).?

How to delete the rows which are duplicate (don’t delete both duplicate records).?

SET ROWCOUNT 1
DELETE yourtable
FROM yourtable a
WHERE (SELECT COUNT(*) FROM yourtable b WHERE b.name1 = a.name1 AND b.age1 = a.age1) > 1
WHILE @@rowcount > 0
  DELETE yourtable
  FROM yourtable a
  WHERE (SELECT COUNT(*) FROM yourtable b WHERE b.name1 = a.name1 AND b.age1 = a.age1) > 1
SET ROWCOUNT 0