Appends a new record to the end of a table that contains the specified field values. The INSERT SQL command has three syntaxes:

INSERT INTO dbf_name [(FieldName1 [, FieldName2, ...])]
   VALUES (eExpression1 [, eExpression2, ...])
INSERT INTO dbf_name [(FieldName1 [, FieldName2, ...])]
   SELECT SELECTClauses [UNION UnionClause SELECT SELECTClauses ...]



Specifies the name of the table for appending a new record. dbf_Name can include a path and can be a name expression.

[( FieldName1 [, FieldName2 [, ...]])]

Specifies the names of the fields in the new record into which the values are inserted.

VALUES (eExpression1 [, eExpression2 [, ...]])

Specifies the field values to be inserted into the new record. If you omit the field names, you must specify the field values in the order defined by the table structure. If eExpression is a field name, it must include the table alias.

If SET NULL is ON, INSERT attempts to insert null values into any fields not specified in the VALUES clause.

FROM Source

Specifies to insert data from an array, memory variable, or Visual FoxPro object. The following list describes valid items for Source:


    ArrayName specifies the array whose data is inserted into the new record.

    Starting with the first element, the contents of the elements of the array are inserted into the corresponding fields of the record. The contents of the first array element are inserted into the first field of the new record; the contents of the second array element are inserted into the second field, and so on.

    When you include the FROM ARRAY clause, Visual FoxPro disregards any default values for fields.


    MEMVAR specifies that the contents of memory variables are inserted into fields with the same names as the variables. If a variable does not exist with the same name as the field, the field is left empty.

  • NAME

    ObjectName specifies a valid Visual FoxPro object, whose property names match the field names in the table for which you want to insert a new record containing the object's property values. You can specify any valid Visual FoxPro object, which you would typically create using the SCATTER...NAME command. For more information, see SCATTER Command.

    If the table has a field that does match an object property, Visual FoxPro disregards the field and leaves it blank as if calling the APPEND BLANK command.

    If the type of an object's property does not match the field type in the table, Visual FoxPro generates a data type mismatch message.


    Use caution when specifying objects derived from Visual FoxPro classes because many native properties have types that might differ from the fields you are working with and cannot be changed.

    If an autoincrementing field exists in the table, you cannot have an object property that matches the autoincrementing field unless you set the SET AUTOINCERROR command to OFF for the data session. Otherwise, Visual FoxPro generates an error. If you use SCATTER...NAME to create the object while SET AUTOINCERROR is set to ON, you can use the REMOVEPROPERTY( ) function to remove any autoincrementing properties to avoid generating an error. For more information, see SET AUTOINCERROR Command and REMOVEPROPERTY( ) Function.

An array, memory variable, or an object is not supported in the Visual FoxPro OLE DB Provider.


Retrieves data from specified fields in a table or cursor, using one or more SQL SELECT statements, for insertion into another table or cursor. However, the SELECT statement cannot contain any non-SQL clauses such as the following: INTO, TO, and PREFERENCE clauses; NOFILTER, READWRITE, NOCONSOLE, PLAIN, and NOWAIT options.

To combine additional SQL SELECT statements with the first SQL SELECT statement, use the UNION clause. For syntax of the SQL SELECT command, which contains the UNION clause, see SELECT - SQL Command.


When you use SQL INSERT with a SELECT statement, make sure that the data you insert is compatible with the data types in the table into which you are inserting. Visual FoxPro attempts to convert the data types in the cursor created by SQL SELECT into the data types in the corresponding table or cursor column into which the data is inserted. If the inserted data is not compatible, precision might be lost, Date data types are converted to Character data types, and so on.

Expand imageRemarks

Expand imageExamples

Expand imageSee Also