Multiple statements in a single Query

N

Nick Gilbert

Hi,

I'm a bit stuck with an access query.

I need to put lots of insert statements into a query like this:

insert into tblAdverts (Filename, URL) values ('sec_10_1.jpg', 'blah');
insert into tblAdverts (Filename, URL) values ('sec_11_1.jpg', 'blah');
insert into tblAdverts (Filename, URL) values ('sec_11_2.jpg', 'blah');

....but whatever I try, I can't make Access run the query. What is the
statement delimiter in Access?

If I don't put in the semicolon, it tells me "missing semicolon at end
of SQL statement", but if I do put it in, it says "characters found
after end of SQL statement".

How on earth do you delimit statements in Access? (I've only used SQL
Server and Oracle before now).

Nick...
 
R

Rick Brandt

Nick said:
Hi,

I'm a bit stuck with an access query.

I need to put lots of insert statements into a query like this:

insert into tblAdverts (Filename, URL) values ('sec_10_1.jpg',
'blah'); insert into tblAdverts (Filename, URL) values
('sec_11_1.jpg', 'blah'); insert into tblAdverts (Filename, URL)
values ('sec_11_2.jpg', 'blah');

...but whatever I try, I can't make Access run the query. What is the
statement delimiter in Access?

If I don't put in the semicolon, it tells me "missing semicolon at end
of SQL statement", but if I do put it in, it says "characters found
after end of SQL statement".

How on earth do you delimit statements in Access? (I've only used SQL
Server and Oracle before now).

Nick...

Access queries are limited to one statement. You can do exactly what you want
in VBA code though.

Dim db as Database
Set db = CurrentDB

db.Execute "First SQL Statement", dbFailOnError
db.Execute "Second SQL Statement", dbFailOnError
db.Execute "Third SQL Statement", dbFailOnError
 

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

Top