Microsoft KB Archive/104332: Difference between revisions
m (Text replacement - """ to """) |
m (Text replacement - "<" to "<") |
||
Line 50: | Line 50: | ||
* firstrec = array containing first record to test | * firstrec = array containing first record to test | ||
* secrec = array containing second record to test | * secrec = array containing second record to test | ||
USE | USE <filename> | ||
* The following command would be modified to include all fields | * The following command would be modified to include all fields | ||
Line 71: | Line 71: | ||
SCATTER TO secrec | SCATTER TO secrec | ||
* Compare each array element to see if other record differs. | * Compare each array element to see if other record differs. | ||
DO WHILE counter | DO WHILE counter < FCOUNT() | ||
IF firstrec(counter) | IF firstrec(counter) <> secrec(counter) | ||
EXIT | EXIT | ||
ENDIF | ENDIF | ||
Line 90: | Line 90: | ||
<ol> | <ol> | ||
<li><p>Issue the following commands: ''''''</p> | <li><p>Issue the following commands: ''''''</p> | ||
<pre class="CODESAMP"> USE | <pre class="CODESAMP"> USE <database> | ||
SET UNIQUE ON </pre></li> | SET UNIQUE ON </pre></li> | ||
<li><p>Create a temporary, unique index. Modify the following command as necessary to include all the fields that make a unique record. ''''''</p> | <li><p>Create a temporary, unique index. Modify the following command as necessary to include all the fields that make a unique record. ''''''</p> | ||
Line 111: | Line 111: | ||
<ol> | <ol> | ||
<li><p>Issue the following command: ''''''</p> | <li><p>Issue the following command: ''''''</p> | ||
<pre class="CODESAMP"> USE | <pre class="CODESAMP"> USE <filename> </pre></li> | ||
<li>Do one of the following:<br /> | <li>Do one of the following:<br /> | ||
<br /> | <br /> | ||
Line 118: | Line 118: | ||
<li>Create a new query by choosing New Query from the Run menu, selecting the Fields check box, selecting the No Duplicates check box, and choosing OK. From the Output list box, choose Table/DBF and type "newtable" (without the quotation marks) in the Name box. Choose the Do Query button to execute the query.</li> | <li>Create a new query by choosing New Query from the Run menu, selecting the Fields check box, selecting the No Duplicates check box, and choosing OK. From the Output list box, choose Table/DBF and type "newtable" (without the quotation marks) in the Name box. Choose the Do Query button to execute the query.</li> | ||
<li><p>Issue the following command in the Command window: ''''''</p> | <li><p>Issue the following command in the Command window: ''''''</p> | ||
<pre class="CODESAMP"> SELECT DISTINCT * from | <pre class="CODESAMP"> SELECT DISTINCT * from <filename> INTO TABLE newtable </pre></li></ul> | ||
</li> | </li> | ||
<li><p>If maintaining the index expressions in the current .CDX file is not required, create a new file as follows. Otherwise, go to step 4. ''''''</p> | <li><p>If maintaining the index expressions in the current .CDX file is not required, create a new file as follows. Otherwise, go to step 4. ''''''</p> |
Revision as of 13:37, 20 July 2020
The information in this article applies to:
SUMMARYYou can use a number of methods to eliminate duplicate records from a database. The method you use will be determined by the specific product being used, whether making a duplicate of the original table is feasible, and the amount of disk space available.
MORE INFORMATIONMethod 1 - Process Database SequentiallyThis method can be used with FoxBASE+ as well as FoxPro. It requires the least amount of disk space to perform the deletions, although it requires a PACK command after all deletions have been completed. The PACK command can require 3-5 times the database size in disk space.
Method 2 - Create a Unique Index and Copy the Records to a New FileThis method can be used with FoxBASE+ as well as FoxPro.
Method 3 - In FoxPro 2.0 or Later, Use SELECT DISTINCT to Create New Table with Only Unique Records
Additional query words: FoxDos FoxWin remove sql Keywords : kbcode FxprgSql Version : 2.50 2.50a | 1.02 2.00 2.50 2.50 Platform : MS-DOS WINDOWS Issue type : |
Last Reviewed: August 12, 1999 |