Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dupes
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Re: Dupes
Miscellaneous
Thread ID:
00562526
Message ID:
00562535
Views:
22
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform