• First of all, I must thank everybody for their valuable comments and insights on this article. During the past several years, I had come across several situations where duplications came up in some or the other tables. Cases were due to either inadequate database design or programming. Everytime I wrote fresh code to solve the problem. The code in this article is a specific part of the overall solution. I have tried to concentrate specifically on a simple and fast method of finding and eliminating duplicate rows. For the sake of concentrating on the specific problem and clarifying it, I created a situation in the article to get the point across. The reason why I did not put in primary keys and foreign keys in there is to concentrate on the specific problem only. Had I put in foreign keys, then a case of consedering the characteristics of FK like NULL, CASCADE, DEFAULT, etc on UPDATE/DELETE would have come up which would have prolonged the article. Probably it could be part of another article.

    The code could be enhanced to include OUTPUT clause for storing deleted rows in an audit table. Similarly, my aim was to solve the problem in one step. So, I did not use temporary tables.

    Again, I refrain from using TRUNCATE TABLE in production unless the entire data set in the table has to be removed. If it is a live table, I would rather use DELETE so as not to affect a high volume of readers adversely.

    Again since I wanted to scan the table only once, I did not use the IN clause with MIN function in the SUBQUERY.

    Once again, I really appreciate your comments and would look forward to more.


    Kindest Regards,

    M Suresh Kumar