Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    5

    Unanswered: Help merging tables

    Hi, im new to DB programming, so help point me in the right direction . . .

    What I want to do is merge two sets of data.

    Im confused as to where to start. I have ideas but havent tried yet because im pretty confused as to how to accomplish the task.

    What I have is two sets of data. The original set, and an newer set. What I want to do is merge the new data into the old.

    I guess what confuses me is the most 'efficient' way to do such. The data sets are large. 70,000 records in the larger of the two.

    I really have no idea where to start. Well, I have one idea:

    While not recordset2.EOF
    recordset1.Filter "key=" & recordset2.key
    If not recordset1.EOF Then
    'the record already exists, update it
    else
    'the record doesnt exist, add it
    end if
    Loop

    but this seems horribly innefficient, having to filter recordset1 for every single record in recordset2. I need to do this with 3 separate databases, each of which will have I think 8 tables. Most of them consisting of atleast 30,000 records each.

    Im too new to SQL to understand a way to do something similar. Basically update the record if it exists, add it if it doesnt.

    I realise its kind of a large topic, but im lost as to which direction to look... if you can just offer tips, or links to something that will point me in the right direction I'd be happy!



    An additional question: Is it possible via ADO/SQL to do something like:
    ...
    cn.Execute "INSERT INTO recordset1 " _
    "SELECT * FROM recordset2", cn, ...

    but with disconnected recordsets?



    Thanks
    Brad

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Hi BradB,

    You're merging the tables correctly.

    Don't worry too much about the efficiency.

    Be sure the data types/sizes/codes are the same in both tables.

    Watch out for "nulls" in required fields.

    Good luck,
    Bruce Baasch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •