Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into - Syntax

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I used the following code trying to add records from a table in another database in a different direcroty to a table in the currently open database:

INSERT INTO [Accident Data] select *
FROM C:\TRAFFIC\DOWNLOAD\DOWNLOAD.[Accident Data];

When I try to execute this code, I get the error Expected end of statement. I have two questions:
1. What is the proper syntax for this code to execute?
2. There is a unique field in the destination table. How can I avoid the program crashing because of an non-unique entry being imported?
 
Well In Access the Table has to be part of the Database
It can't refer to an external file on the C: drive.
So if you import it or Link it then refer to it directly it will work.
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Hi Gene,
If this is an Access database you're trying to pull data from, you might try this:
From the database window:
File-Get External Data-Link Tables, and select the database and table you'd like to work with. Assuming you have permission, you could now access the data in the table as though it resided in your first Db. In your case as the two tables have the same name "Accident Data", the new linked table would automatically be named "Accident Data1"
Go to a new query and select the table you want the data to come from. Even far away it should appear on the list. Double-click or drag the field(s) you'll want to add, then go up to the tool bar and find the "query type" button (left of !). Choose append query and you'll be prompted for the table to append to. Set in the "Append to" row field names (if it doesn't do it for you automatically), and add any criteria you may require. If you are working in SQL, flip to SQL view, copy~paste to where ever and you are done!

P.S. If you want the whole table copied in to your Db, File-Get External Data-Import...! Hope that works for you!
Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top