Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dupes
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Re: Dupes
Divers
Thread ID:
00562526
Message ID:
00562535
Vues:
23
>Hi All:
> I have duplicate records in one table that is part of Sql Server. How can I delete all the duplicate records in the table and preventing this from happening again in the future ?
>Thanks

I'm not familiar with SQL Server, but I think, this would work:
select count(*) as cntDups, KeyID from yourtable ;
       group by KeyID ;
       having cntDups>1 ;
       into cursor curDups && Will contain one record per each dups

delete from YourTable where KeyID not in (select KeyID from curDups)
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform