Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Append or Update Query

I want to run a query that updates a record I a table if the record already exists.   But if the record does not exist I want it to create a new record in the table.

The source table is "Source".  The destination table is "Destination"

The both have a key field named "RecordID"

If I just try to run an update query it fails because the record isn't there.  But if I run an append query it works fine if the record is already there.

Confused!!

--Steve
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What Rey said!  (no points please)

Some people call this an UPSERT query.  In SQL Server, they have a similar query syntax called MERGE which gives you the ability to Update and Append at the same time, and you can even get a count of how many of each action are completed.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial