Search this blog

Monday, June 1, 2009

Delete Duplicate rows

Following Query Format Helps to delete duplicate records from a SQL Table

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

1 comment:

  1. Hi Manas,

    Thanks for visiting my site, tell me what you are not understand here?

    ReplyDelete