Appending tables

  • Thread starter Thread starter CAM
  • Start date Start date
C

CAM

Hello,

I have 5 tables:
Table A
Table B
Table C
Table D
Table E

All I want to do is to append tables A-E to Table F.

What will be the quickest way to go about it. Any tips will be appreciated.
Thank you in advance.
 
If the tables have identical field names, of the same data type, in the same
order, and there is no issue with duplicated ID values, you could do it by
with 4 append queries.

To do the job programmatically:
Dim db As DAO.Database
Dim strSql As String

Set db = dbEngine(0)(0)
strSql = "INSERT INTO E SELECT A.* FROM A;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT B.* FROM B;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT C.* FROM C;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT D.* FROM D;"
db.Execute strSql, dbFailOnError
 
if you dont want to
program,
another way is to
create a Append Query
like this..

INSERT INTO F
SELECT * FROM
(
SELECT*FROM A
Union
SELECT*FROM B
Union
SELECT*FROM C
Union
SELECT*FROM D
Union
SELECT*FROM E
) AS ABCDE
 
Thanks Again I appreciate your advice

Allen Browne said:
If the tables have identical field names, of the same data type, in the
same order, and there is no issue with duplicated ID values, you could do
it by with 4 append queries.

To do the job programmatically:
Dim db As DAO.Database
Dim strSql As String

Set db = dbEngine(0)(0)
strSql = "INSERT INTO E SELECT A.* FROM A;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT B.* FROM B;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT C.* FROM C;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT D.* FROM D;"
db.Execute strSql, dbFailOnError
 
Back
Top