Append Query for Records That Already Exist (1 Viewer)

Tor_Fey

Registered User.
Local time
Today, 00:58
Joined
Feb 8, 2013
Messages
121
Good Afternoon all;

I have two test tables I’m trying to perform an experiment on, test1 & test2.
In both these tables; I have a field called ‘yearis’ which is a text field. What I’d like to do is create an append query that will: Update records in table 2 if it exists or append a record from table 1 if it does not exist. According to the ‘yearis’ field in test1.

Is there a way to do this with a standard append query?

Many Thanks for your help.

Kind Regards
Tor Fey
 

Minty

AWF VIP
Local time
Today, 00:58
Joined
Jul 26, 2013
Messages
10,366
Short answer no. You need two queries, an append for the new data, and an update for existing.

They are created differently in SQL, and perform different actions, so can't be combined.
 

Minty

AWF VIP
Local time
Today, 00:58
Joined
Jul 26, 2013
Messages
10,366
Now why didn't I think of that... :)
 

isladogs

MVP / VIP
Local time
Today, 00:58
Joined
Jan 14, 2017
Messages
18,209
Clever.
Is there a recognised name to describe this method which does both APPEND & UPDATE in one query.

UPAPP? UPEND? APPDATE? APPUP?
I like UPEND :D
 

Minty

AWF VIP
Local time
Today, 00:58
Joined
Jul 26, 2013
Messages
10,366
Apparently it's called an UpSert, but that's probably a bit too close grammatically in this day and age, to an UpSkirt , which is an entirely different and NSFW activity!
 

isladogs

MVP / VIP
Local time
Today, 00:58
Joined
Jan 14, 2017
Messages
18,209
Ah yes - I remember Upsert. Thought I'd seen it before.
As far as I'm concerned, UPEND is a much better name
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:58
Joined
Feb 19, 2002
Messages
43,220
I'm pretty sure this method only works with Jet/ACE. I don't believe it works in SQL Server, just FYI.
 

Users who are viewing this thread

Top Bottom