Microsoft KB Archive/109578

{| = PRB: CREATE FROM Command Ignores Indexes and Filters =
 * width="100%"|

ID: Q109578

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, and 2.6
 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, and 2.6
 * Microsoft FoxPro for Macintosh, version 2.5b

SYMPTOMS
Indexes or filters set to a database created either manually or with the COPY STRUCTURE EXTENDED command will be ignored when you are using the CREATE FROM command.

RESOLUTION
There are three ways to work around this behavior:

 Use the SORT command. -or- Copy the fields to an array, perform an ASORT on the array, and then create the table from the array. -or- Use an SQL SELECT command with an ORDER BY clause to sort the fields. (For an example of this, see "Workaround" in the "More Information" section below.)

Steps to Reproduce Behavior
The following steps use the CUSTOMER.DBF from the TUTORIAL subdirectory under the main FoxPro directory.

Issue the following commands from the Command window or copy them into a program (.PRG) file and run the program file:

USE customer COPY STRUCTURE EXTENDED TO test USE test INDEX ON field_name TAG field_name ADDITIVE SELECT 0 CREATE result FROM test LIST STRUCTURE The field names are not in ascending order. The field name CNO is before the COMPANY and CONTACT fields.

Workaround
In order to have the fields sorted, use the following code:

USE customer COPY STRUCTURE EXTENDED TO test USE test SELECT * FROM test ORDER BY field_name INTO TABLE query SELECT 0 CREATE result FROM query LIST STRUCTURE Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 pssbug2.50b pssbug2.60 KBCategory: kbprg kbprb KBSubcategory: FxprgSql
 * }