Merge 2 access databse

  • Hi All

    I have 2 Access database but having different data in it. Is there a way I can pull up the data from both the database in to one database.

    FYI the primary Key in both the database are same . Is there a way I can merge the data.

    Thanks

    Gaurav

  • Your Primary Keys are Autonumber in both DB or other datatype!?

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Yes,

    Primary keys are autonumber

  • OK! Make third MS Access file then import the both tables from both DB. After that go to querys and open new query in SQL mode then write:

    SELECT * FROM TABLE1

    UNION ALL

    SELECT * FROM TABLE2

    Save it as query! These Select statement together with UNION All collect the data in one place, then after you create the query go the query design and create another one but this time as make table query in the current DB put all columns in the query run it, it will creates the new table! So you should design this table just adding one more column with autonumber datatype!

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • simple steps:

    After importing the both Tables! Create new query in SQL mode:

    SELECT * FROM TABLE1

    UNION ALL

    SELECT * FROM TEBLE2

    Save it as Union_all

    then

    Start new query also in SQL Mode then write:

    This code replace the Make Table Query action!!!

    SELECT * INTO FINAL_TABLE

    FROM Union_all

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Thanks for your reply

    I was able to merge two table however the final table has no more primary key and also in my database there is a relationship between different tables and I also have lukup tables.

    If I merge all the tables by the above method will the relationship still holds gud

  • Gaurav (1/8/2009)


    Thanks for your reply

    I was able to merge two table however the final table has no more primary key and also in my database there is a relationship between different tables and I also have lukup tables.

    If I merge all the tables by the above method will the relationship still holds gud

    On final table you should add one more column with autonumber datatype, so I don't have the info about you relationship between tables but you should know when these two tables have from beginning the autonumber fields that starts from 1!

    This action to merge that two tables should be just for any collection of the data or just for analyzing something with these data! Anyway they are not available to use with other tables in relationship before, because in Final Table you have the values that they are not unique anymore!

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply