Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating records in FoxPro tables
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00565010
Message ID:
00565087
Vues:
21
>>>>>>>>>I have some dupe records that are causing me problems and I need to delete one of the dupes for each record in several tables. Is there a way to do that without deleting each individual record by hand? Is there a way to do it using the command line?
>>
>>>>Ok, last try before I'll actually run a test :)
>>>>
>>>>select KeyID, count(*) as CntDups from yourtable group by KeyID ;
>>>>       having CntDups > 1 ;
>>>>       into cursor curDupes
>>>>if _tally>0 && There are dups in table
>>>>  index on KeyID tag KeyID
>>>>  scan
>>>>  if seek(KeyID,'YourTable',"KeyID") && should be always found
>>>>     * select YourTable
>>>>     delete in YourTable && One duplicated record is deleted now
>>>>   endif
>>>>   endscan
>>>>endif
>>>>use in curDupes
>>>>
>>>Looks like it'll work for one duplicate per KeyId. What if there're more than one?
>>
>>See the highlighted part in the original question :) What was asked - that was answered, nothing more, nothing less :)
>>
>>Of course, if we expand the original problem, I have to think a little bit more :)
>
>Ok, you got me :)

:) On the serious note, if we need to delete all dups but one, I think, Ron's solution is the perfect one and it's a standard for this kind of situation.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform