Published on System iNetwork (http://systeminetwork.com)
Deleting Records with Duplicate Data -- Revisited
By tzura
Created Jul 25 2002 - 04:00

In the last issue, we included a tip on deleting duplicate records using SQL. We received a considerable amount of reader feedback on the item. One correspondence from Derek Sutcliffe suggests a variant that he suggests will improve performance, particularly on large files.

Following is Derek's suggested replacement, which lets you view the duplicates to be deleted:

  Select RRN(B) From MyLib/MyFile B, Mylib/Myfile C
    Where B.LastName = C.LastName and RRN(B) > RRN(C)
His suggested replacement that performs the deletion of duplicate records is as follows:
  Delete From MyLib/MyFile A
    Where RRN(A) in 
     (Select RRN(B) From MyLib/MyFile B, Mylib/Myfile C
        Where B.LastName = C.LastName and RRN(B) > RRN(C))

Thanks for sharing this information with readers, Derek.

© 2010 Penton Media, Inc.

Source URL: http://systeminetwork.com/node/60705