Update else Insert

  • Thread starter Thread starter RC-
  • Start date Start date
R

RC-

I need to write a query that will Update data if it exists or Insert if it
does not exist.

I have been trying to modify this query, but I don't really know the syntax:

IF EXISTS (SELECT * FROM tblDefaults WHERE defPhone = 9155883738)
UPDATE tblDefaults
SET defCostCode = '1-57000-5', defProjectID = 'C06115'
WHERE defPhone=2015551212;

Can anyone tell me how to Update else Insert the data?

TIA
RC-
 
I don't believe this can be done in a single JET query. I believe you will
need to use code to detect whether the record exists and execute either an
update or insert query accordingly.
 
OK, thanks for the quick reply!!

RC-

Brendan Reynolds said:
I don't believe this can be done in a single JET query. I believe you will
need to use code to detect whether the record exists and execute either an
update or insert query accordingly.
 

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

Back
Top