multiple queries in access

dhx10000

Registered User.
Local time
Today, 11:31
Joined
Mar 3, 2006
Messages
12
How can I get around not being able to create multiple statements in a single query? For example, I tried to do this:

DELETE * FROM UniqueDates;
INSERT INTO uniqueDates ( Entry_Date )
SELECT entry_date
FROM [SELECT Entry_Date FROM BarcelonaInternalActions
UNION SELECT Entry_Date FROM QPTActions
UNION SELECT Entry_Date FROM TokyoInternalActions
UNION SELECT FORMAT(Entry_Date , "Short Date")
FROM RDActions
]. AS U;

but I received an error. I am trying to clear out a database and insert new records every time I run this query. I think maybe a better option would be to append any new records into the database rather than deleted and inserting a fresh batch of records. What do you think?
 
Create a procedure to run your queries. If you don't know how, then create a macro that runs the queries in the desired order and convert the macro to code.

If the table has a primary key that will prevent the addition of duplicates, the append method is more efficient. You can turn off the warning messages if you don't want to see the error message that you'll get for attempting to append duplicate rows. If you need to update existing records as well as append new ones, use a right join. Search for "append update query" to see the exact syntax for the query that will append new rows and update existing ones.
 

Users who are viewing this thread

Back
Top Bottom