Update Query w/ Unmatched Records

G

Guest

Is there something special I have to set up norder for an update query to
add and records that it does not find a Primary Key match for.

Example: If T2 has an Employee ID number not found in T1(e.i. a new
employee), the update query will add that records information to T1.
 
G

Guest

An "Update Query" modifies existing data so if the data does not exist then
it can not modify anything. Maybe you want an Append query.
 
G

Guest

We are a national company, our office is now that the same location as the
General Office. WHen send be an updated table On the 1st each moth. THis
update includes any promotions, title changes, address changes etc... for
each employee I have. Included in this update is the complete record data for
any new employees. I have to run an update query already to pick up the
changes to title, address etc...
What I need to know is if there is some way to get it to also update my
table to include the new employee record? An append query would try to
re-create all 900 employees.
 
G

Guest

Sorry could not type...


We are a national company, our office is not at the same location as the
General Office. When they send me an updated table on the 1st of each month,
this update includes any promotions, title changes, address changes etc...
for each employee I have. Included in this update is the complete record
data for any new employees. I have to run an update query already to pick up
the changes to title, address etc... What I need to know is if there is some
way to get it to also update my table to include the new employee record? An
append query would try to re-create all 900 employees.
 
J

John Spencer

Do you have a primary key for each employee? IF so, an append query will
not append all the employees - it will add the employees you don't have and
will generate an error message for all the existing ones. You can avoid
even that by structuring your append correctly.

FOR example (assuming EmployeeID is unique in both tables)

INSERT INTO YourTable (EmployeeID, FirstName, LastName)
SELECT GO.EmployeeID, GO.FirstName, GO.LastName
FROM GeneralOfficeTable as GO LEFT JOIN YourTable as Y
ON GO.EmployeeID = Y.EmployeeID
WHERE Y.EmployeeID Is Null

As always, backup your data first or try this on a copy of your data to see
if you get the desired results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top