If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Help merging tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-03, 00:03
Brad_B Brad_B is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 02-10-03, 09:45
Bruce A. Baasch Bruce A. Baasch is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On