Insert multiple rows values with MS Access

CabbageCake

New member
Local time
Today, 15:34
Joined
Dec 29, 2011
Messages
3
Hi guys,
I have a following table:
Code:
create table animal
(
animal_id integer not null primary key,
name varchar(40) not null,
spieces varchar(40) not null
)

I would like to fill it with lots of records which I want to insert into at time. But I don't know how I can start it:)

Here is my records to insert:
insert into animal (animal_id, name, species)
values ( (1,'Foxi Maxi', 'dog'), (2, 'Dodo',' duck') , (3, 'Garfield', 'cat' ) )

I've found a kind of solution with these problem using the Union All keyword, but it isn't work for me (I use Access 2003)
INSERT INTO

SELECT 'x1','y1'
UNION ALL


Is there any way to insert multiple rows with MS Access?
Any help would be greatly appreciated!
Very thanks.
 
Where do you have the data you want to add now? Is it in a spreadsheet?

insert into animal (animal_id, name, species)
values ( (1,'Foxi Maxi', 'dog'), (2, 'Dodo',' duck') , (3, 'Garfield', 'cat' ) )

The above form of the append query is only good for adding 1 record




INSERT INTO

SELECT 'x1','y1'


The above form of the append query can be used for appending multiple records but the data has to be in another table or query. The syntax you show is not quite correct. This is the correct syntax:

INSERT INTO tablename (fieldname1, fieldname2)
SELECT table2.field1, table2.field2
FROM table2
 
Use the query like this:
INSERT INTO Product (Code,Name,IsActive,CreatedById,CreatedDate )
SELECT *
FROM (SELECT '10001000' AS Code,'Blackburn sunglasses' AS Name,1 AS IsActive,1 AS CreatedById,'2/20/2015 12:23:00 AM' AS CreatedDate FROM Product
UNION SELECT '10005200' AS Code,'30 panel football' AS Name,1 AS IsActive,1 AS CreatedById,'2/20/2015 12:23:09 AM' AS CreatedDate FROM Product) ;
 

Users who are viewing this thread

Back
Top Bottom