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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert into SQL Statement

Status
Not open for further replies.

dragonsel

Programmer
Sep 9, 2002
11
0
0
AU
Would someone be able to tell me what is wrong with this SQL statement? - I am trying to work around the spaces in the field names as they can't be changed.

INSERT INTO tblAppraisal![Appraisal ID], [Personal ID], [Date] ".... quite a few more fields
SELECT * FROM tblAppraisal1

I have looked in VBA help to insert multiple records into an existing table and it suggested using the INSERT INTO SELECT FROM statement.

Background Info:

I have a database where the data in a number of tables has been split into 2 databases. I am currently trying to put the 2 databases back into one.

The table structure is exactly the same in both tables and there is no duplicate data. Each table has an autonumber primary key (as they were previously in 1 table there are no duplicates).

I am trying to insert 54 records from tblAppraisal1 (imported into the 1st database from the 2nd) into tblAppraisal and keep the primary keys intact as they relate to foreign keys in other tables.

It sounds insane I know but that is management's whims for you :)

Thanks heaps,
Selene
 
INSERT INTO tblAppraisal ([Appraisal ID], [Personal ID], [Date], nextfield )
SELECT Field1, field2, field3, field4 FROM tblAppraisal1

etc

John
 
Thanks, I'll give it a go and let you know.

Selene
 
Thanks heaps John - worked well and saved me a huge headache.

Selena
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top