|
Subject:
|
Need to merge several tables with unlike structure
|
|
Posted By:
|
CORiverRat
|
Post Date:
|
12/13/2005 1:30:00 PM
|
Here is my problem. I have several different excel spreadsheets from several different sources (each has inventory data, taken by several different people at different times and one is generated electronically by our network team). I have brought them all into access and created tables from them. Each one has its own set of fields although they all have one field in common (host name). My problem is that I need to merge all of these into one database, and in doing so keep all the records from each database that are not in the other databases. I am willing to do this in a multistep process (create a query, merge two to a table, create a new query using this table and the next table on the list and so on).
I am new to Access and am looking for any help anyone can give me on how to best attack this problem.
Thanks in advance for any help you might be able to provide or point me to.
Roger
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
12/13/2005 2:48:58 PM
|
This is pretty easy if you have a lot of fields that have the same sort of information in them, but different field names.
What I have done it to create a query on the first table with all of the fields in it, but rename the ones you need to according to a pre-determined naming convention, like this: NewName:([OldName])
Then turn the query into a Make Table Query, then make a new table that is going to store all this accumulated data.
Then from the other tables, do the same thing, but make them Append queries, and then append those tables, of course sticking to your naming convention.
Then once you have all the tables consolidated into one table, do a Duplicates query to find your duplicate entries (if you want to get rid of them.)
This should take about as long as it takes you to read this.
HTH
mmcdonal
|
|
Reply By:
|
CORiverRat
|
Reply Date:
|
12/13/2005 4:21:05 PM
|
Thought of doing that, but don't want to have duplicate records from each database, rather want the data to accumulate into the records... Like in the first merge with the network database (most inclusive) pick up machine type, sw load and room number from one manual inventory. Then take results of that and pick up other new fields like jack number from another database (as well as a room number if they show it and so on.
Tried using a union query of the first two but it gives me duplicate records.
Thanks
Roger
|
|
Reply By:
|
kindler
|
Reply Date:
|
12/13/2005 4:33:36 PM
|
Eliminating duplicate records takes almost no time at all, and can be done in one sweep at the end.
|
|
Reply By:
|
CORiverRat
|
Reply Date:
|
12/14/2005 10:41:54 AM
|
Problem was, the dup record each had their own information in them, they didn't merge into a single record with dups, that I could handle. Instead I would have one record with certain fields, another record with other fields etc. One thing I did try is multiple queries with changing my joins each time so I could pull in one group of records, then another group of records. This worked best so far but I just figured their had to be an easier way to pull in the records and create one record that held all the info I had from multiple tables.
Roger
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
12/14/2005 11:58:22 AM
|
Oh, that is easy. Just pull in all the fields from both tables, but only use the one or several common fields once from each table, and then join the tables on the common field.
For example:
tblOne OneID - PK FName LName Username (linked field) Address City State Zip
tblTwo TwoID FName LName Username Email Hobby
qryLinkTables (join tblOne and tblTwo on UserName) tblOne.FName tblOne.LName tblOne.UserName tblOne.Address tblOne.City tblOne.State tblOne.Zip tblTwo.Email tblTwo.Hobby
Does this help?
mmcdonal
|