Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleteing the last duplicate
Message
De
27/10/2013 18:38:50
 
 
À
27/10/2013 18:04:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01586533
Message ID:
01586536
Vues:
62
>Hi All:
>What's the easiest and most elegant way to remove the SECOND duplicate.
>IOW, when there is a dupe, get rid of the second record.
>Thanks,
>Yossi


There may be a better way. I have used this.
* Prepare the table for the operation
SELECT tableWithDuplicates
ALTER TABLE ADD COLUMN lDuplicate L

* Mark everything initially as a duplicate
REPLACE ALL lDuplicate WITH .T.

* Create an index of unique records
INDEX ON my+Unique+Key+Fields UNIQUE TAG dupTemp

* Mark every unique record as not being a duplicate (the nature of the INDEX ON command mandates that the UNIQUE records are top-most in row order)
REPLACE ALL lDuplicate WITH .F.

* Remove the index
SET INDEX TO

* The records which are marked lDuplicate = .T. are the second (and later) duplicates

* Delete those records and then PACK, mark lDeleted = .T., or whatever...

ALTER TABLE DROP COLUMN lDuplicate
DELETE TAG dupTemp
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform