If I have a table of excel data that I will be consistently importing
with new data. The acccess table I will be importing into has an
foreign key for two fields name and location. If the name and location
doesnt exist what is the best method to ensure that the new data is
updated to its main table?
|
|
0
|
|
|
|
Reply
|
flebber.crue (78)
|
1/23/2011 12:49:08 PM |
|
Well, we lack quite a bit of information about table structure.
In general, I would import the data into a work table (or set a link to the
Excel "table" and then use an append query to add new records to the table
(SomeLocationTable0 that contains the values for location and name.
INSERT INTO [SomeLocationTable] ([Name],[Location])
SELECT Temp.Name, Temp.Location
FROM WorkTable as Temp LEFT JOIN [SomeLocationTable]
ON Temp.Name = [SomeLocationTable].Name
AND Temp.Location = SomeLocationTable.Location
WHERE SomeLocationTable.Name is Null
This assumes the the Primary Key in SomeLocationTable is autogenerated (it is
an autonumber).
Then after the above runs you import the records from the WorkTable into your
destination table.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
On 1/23/2011 7:49 AM, flebber wrote:
> name and location
|
|
0
|
|
|
|
Reply
|
JSPENCER1 (59)
|
1/24/2011 2:20:18 PM
|
|