Select

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

Hoe do you you select from one table (Table1) certain records and INSERT
into (Table2) using SQL.

Thanks
DS
 
DS said:
Hoe do you you select from one table (Table1) certain records and
INSERT into (Table2) using SQL.

Use an append query. See the help file. book "Microsoft Jet SQL
Reference", subheading "Data Manipulation Language", topic "INSERT INTO
Statement". Or type "append query" in the online help, which will give
you a topic on how to do it with the query designer; make such a query
and then switch it to SQL View to see the SQL it generates.
 
DS said:
Hoe do you you select from one table (Table1) certain records and INSERT
into (Table2) using SQL.

Thanks
DS

Hi DS !

In our example, destination Table2 has 3 Fields: Name, Address, Fone
and our source Table1 has several fields, but 3 on our focus: CustomerName,
CustomerAddress and CustomerFone.

The names must match with the destination table - thus...

Criteria = "INSERT INTO Table2 " _
& "SELECT CustomerName AS Name, CustomerAddress AS Address, CustomerFone
AS Fone " _
& "FROM Table1 " _
& "WHERE " & Condition & " " _
& "ORDER BY CustomerName;"
DoCmd.RunSQL Criteria ' Execute the SQL comand

That is faster than any procedure with recordsets, in VBA.

Good luck...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top