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!

Compare two databases

Status
Not open for further replies.

Shazza

Technical User
Aug 21, 2000
38
0
0
NZ
I have two databases, with identical tables in them. One with older data. I need to update some of the tables in the older database with the changes from the new database.
 

Hi,

Always a pain with not updated stuff, isn't it?
I don't think that there is anyway arounf the hard way. Open up a recordset from each database tabel, make sure that they are ordered in the same way. Loop through the updated recset while compareing each row. If thay are different uyo'll need to add it.
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I was afraid of that. Is there anyway of importing a table from an existing database to the other database through code.
 

Yes you can use

INSERT INTO target [IN externaldatabase] [(field1[, field2[, ...]])]
SELECT [source.]field1[, field2[, ...]
FROM tableexpression

but I am sure that it will raise an error if the primary key is the same (haven't tried it thought)

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I was thinking of deleting all the data and then doing the insert into query to update the table with the new data, only problem is that same of the tables have autonumber for primary keys, and these are used for reference.

Is there any way of running an append query that doesn't reset the autonumbering?
 
No way (but the hard way I mentioned abouve). The autonumber is deleted when you delete a row.

And the hard way is not that bad I guess that you coudl do it in ~20 line of code.

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
God d... my typing is miserable this morning -well it is very early... Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top