SQL Insert Statement

K

Kathy

I have a problem inserting multiple rows of data into an
Access 2002 table using the INSERT INTO statement.

I can insert only one row using INSERT INTO <tablename>
VALUES <constants>

Can anyone help with this?
 
J

John Vinson

I have a problem inserting multiple rows of data into an
Access 2002 table using the INSERT INTO statement.

I can insert only one row using INSERT INTO <tablename>
VALUES <constants>

Well... yes. That's quite correct; you only have one set of constants
available so you will only get one record!

To insert multiple records you must use an Append query from another
table, e.g.

INSERT INTO <targettable>
SELECT <fields>
FROM <sourcetable> WHERE <conditions>;

As many records as are selected from the source table will be
inserted.

Note that if (for some strange and unaccountable reason) you wanted to
insert 100 identical records from a manually entered list of values,
you could use an auxiliary table; I usually have a table NUM with a
single numeric field N with sequential values. You could create 100
records by using

INSERT INTO <targettable> (Textfield, numberfield, datefield)
SELECT "SomeTextValue", (1), #10/15/2001#
FROM Num
WHERE N <= 100;
 

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