Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicate deleter
Message
 
 
To
12/04/2011 13:38:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01507056
Message ID:
01507058
Views:
67
Strange code. Why not delete using SQL-DELETE? Do you want to delete based on a particular field name having a PK in a table?

IF so,
delete MyTable from MyTable INNER JOIN
(select FieldName, Min(ID) as IDToKeep from myTable GROUP by FieldName HAVING count(*) > 1) X
ON MyTable.FieldName = X.FieldName
where MyTable.ID > X.IDToKeep
>Here is a bit of code I cobbled up to delete duplicates.
>Help yourself or correct my errors if there are any
>
>
>SELECT [Your table name here]
>COUNT TO EndOfTheFile
>? EndOfTheFile
>? " Searching for duplicate records"
>FOR Outside = 1 TO EndOfTheFile
>	GOTO Outside
>	GoodRecord = ALLTRIM(Field name here)
>	FOR Inside = (Outside + 1) TO EndOfTheFile
>		GOTO Inside
>		CheckedRecord = ALLTRIM(Field name here)
>		IF CheckedRecord = GoodRecord
>			DELETE
>		ELSE
>			DUMMY = DUMMY + 1
>		ENDIF
>	NEXT Inside
>NEXT Outside
>* BROWSE
>* PACK
>CLOSE TABLES
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform