Multiple inserts

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I need some help with SQL which I am going to put into
some code.
I want to know how to insert more than one row at a time.
e.g. for entering one row I have the SQL
INSERT INTO MYTABLE VALUES ("myname");


Please help.
Thanks.
 
Hi

I need some help with SQL which I am going to put into
some code.
I want to know how to insert more than one row at a time.
e.g. for entering one row I have the SQL
INSERT INTO MYTABLE VALUES ("myname");

As long as you're using VALUES you can only do one row at a time (AFAIK).
Normally to insert multiple rows at once you would be pulling them from
some other table or query so there would be a SELECT statement instead of
the VALUES list.
 
Hi

Thanks.
So I guess the best way is just to put a loop in the
code? - since it will be coming from another source other
than the database.
 
Hi

Thanks.
So I guess the best way is just to put a loop in the
code? - since it will be coming from another source other
than the database.

What is the other source? If it is something you can link to and treat as
a table then you should be able to use the SELECT method. Otherwise yes, I
guess you would have to use a loop. It might be more efficient in that
case to open an editable RecordSet and use the ADD method in your loop
rather than executing multiple INSERT queries each inserting a single row.
 
If this is for a lot of data on a regular (batch) basis you might be better
writing out the data as a csv importing that into a tempory table in access
then updating from the temporary table.

It is very easy to make the whole process almost automatic, and access has
useful conversion tools.

Peter
 
Back
Top