Howdy folks. I"m hoping a certain thing is possible, and hope you can direct me on the right path.
TLR: Can I write a SQL query that will...
1. Check if a record in the "to import" table has a matching entry in the "Main data" table
2. Update the main data table if there's a match.
3. Append the record if there's not a match.
4. Loop back until all records have been processed.
I figure I can do an if-then command where if there's a match, run the update, if there's not then do the append. However this is an order of magnitude of SQl coding above anything I've ever done, so I want to be sure it's even possible before I start digging into it.
Long version
I've inherited a database with a defective update process. In theory, seven queries are run in order to update and append a main data table as appropriate. However the queries have NEVER worked outside of a thin slice of test data performed offline in a controlled environment, and last year I had to do about 80 hours of manual data entry to get the data in for the year. The new year's data is coming up, and I've learned a year's worth of Access in that time, and I'm hoping to do something other than do it manually. Our main data table is also on a Sharepoint that I think is running on an ISDN line in a basement somewhere, so any attempt to run a mass-update fails spectacularly.
What I'd like to do is replace those seven queries with a single robust query that will go through the 'import' table line by line, updating and appending as applicable. Is this something that can be done in a SQL query, or are SQL queries limited to just append OR update in a single query?