Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

update insert msaccess

i wish to update or insert if missing into an msaccess database using asp.

i was trying something like:

IF EXISTS (SELECT * FROM Table1 WHERE Column1='SomeValue')
    UPDATE Table1 SET (...) WHERE Column1='SomeValue'
ELSE
    INSERT INTO Table1 VALUES (...)

and

UPDATE Table1 SET (...) WHERE Column1='SomeValue'
IF @@ROWCOUNT=0
    INSERT INTO Table1 VALUES (...)

INSERT or UPDATE by themselves work fine. but when i use the both with one of the methods it fails.

like image 993
Noam Smadja Avatar asked Mar 04 '26 01:03

Noam Smadja


1 Answers

You cannot run two sql statements at once in Access. You must update and insert in two separate operations.

like image 183
Fionnuala Avatar answered Mar 07 '26 12:03

Fionnuala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!