Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting Duplicate Records In Table
Message
From
12/04/2013 12:35:34
 
 
To
12/04/2013 10:06:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01570796
Message ID:
01570803
Views:
48
>Using the following code I could Get the number of counts for Duplicate records. But How do I delete the Duplicate entries, i.e I just want to keep the one single entry for my account Number, Preferebly the last one.
>
>
>SELECT Accountno As Account_No,COUNT( * ) AS DupCount;
>  FROM New_master ;
>  INTO CURSOR Duplicates ;
>  GROUP BY Accountno ;
>  HAVING DupCount > 1 
>
>
>I tried Select * from New_master UNION Select * from New_master . But It didn't worked.

Assuming these records have a primary key and that key is used to link account numbers to transactions, you must be careful that the "duplicates" you delete have no links to the transactions. Failure to do so would leave "orphan" transactions.

I recommend that, instead of trying to accomplish this purge in a sequel statement, you write a program that scans the duplicate candidates and examines possible relationships and corrects them.

Hope this helps,

Ken
Previous
Reply
Map
View

Click here to load this message in the networking platform