Home  Fees/Services  Access Examples  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

Access Query Examples
SQL Insert Into Query
Access Append Query Example

Insert Into SQL Tutorial SQL Queries Microsoft Access 2007 Query

Access Database Tutorials>SQL Queries>Access Insert Example

Download Access Program


Aggregate Functions
Child/Parent Table Query
Access Choose Function
SQL Choose Function +
Crosstab/Pivot Query
SQL Crosstab Query +
Access DateTime Query
SQL Delete Query
External Link to Tables
Filter Report Records
Group By Clause
Having Clause Query
Histogram Query
Insert Into SQL Query
Master/Detail Updates
SQL Order By Dynamic
Parameter Query
SQL Predicate Example
Self Join Query
Access Scalar Query
Select Statement
Select Top 1 Query
Union Query Example
Update Query Example


Insert Into Query

The insert into SQL statement is the DML (data manipulation language) command to use to append new records to a table in your relational database.

The basic syntax of the Insert Into SQL query for a single record is:

Insert Into TableName (FieldName1, FieldName2) Values (Value1, Value2);

For multiple records gathered from other tables or external sources the Access insert into SQL query is slighty different:

Insert Into TableName (FieldName1, FieldName2) Select FieldName1, FieldName2 From TableName;

The full syntax of the Access insert into SQL query statement from Microsoft Access help is:

INSERT INTO target [IN externaldatabase] [(field1[, field2[, ...]])] SELECT [source.]field1[, field2[, ...] FROM tableexpression;

Where:

Insert Into Query Append

Note: The ending semicolon is a required component of all SQL statements.

Now the insert into query with real column and table names for a single row:

Insert Into M_Employees (Emp_ID, Emp_Name, Emp_Start_Date) Values (00212, "Joseph Dean", #01/02/06#);

Note that text values are bounded by quote marks and date values are bounded by pound signs in the insert into query.

Multiple row inserts using the select statement alternative - a variation of the insert into query.

Insert Into M_Employees (Emp_ID, Emp_Name) Select Emp_ID, Emp_Name From MyLinkedSpreadsheet Where Emp_Status="New";

Note that we restrict the number of records to only those records with a status value of 'New".

More Append Query Examples:

Docmd RunSQL Access Append Query

SQLText = "INSERT INTO T_Orders ( Order_Numb, ITEMDESC, XTNDPRCE, QUANTITY ) SELECT SOPNUMBE, ITEMDESC, XTNDPRCE, QUANTITY " & _ ...
www.blueclaw-db.com/docmd_runsql_example.htm
 

Concatenate Records Insert Query

RunSQL ("INSERT INTO T_Patient_alrgy ( Patient_ID, Allergy ) " & _ " SELECT " & Patient_ID & ",'" & hold_alrgy & "'") End Function ...
www.blueclaw-db.com/concatenate_multiple_records_one_field.htm









Contact Information

SQL Queries
MS Access SQL Queries 2007 2003 2000  All Windows Versions