How do I insert multiple rows?

NoviceMe
10-20-2004, 02:16 AM
Hi,

I am trying to insert multiple rows into my database, but I am not sure how to do it, I have been inserting each line, by writing an insert statement for each - is there a quicker way? I also have the records in a text file, so Is there a way of writing this statement so that it imports all rows from the file, regardless of how many rows there are? I am using SQL Anywhere v5. and am fairly new to SQL. My current code is:


INSERT INTO work_type (team_code, date_of_event, start_time, event_name) VALUES ('AT1-01', '2004/01/12', '20:35');
INSERT INTO work_type (team_code, date_of_event, start_time, event_name, ) VALUES ('AT1-01', '2004/04/01', '01:45',);
INSERT INTO work_type (team_code, date_of_event, start_time, event_name, ) VALUES ('AT1-01', '2004/01/11', '17:04');
INSERT INTO work_type (team_code, date_of_event, start_time, event_name, ) VALUES ('AT1-01', '2004/01/23', '00:00');


Thanks in advance

Shurik12
10-20-2004, 02:44 AM
Hi,

DId you try something simlar to:


Insert Into Table1 (Field1,Field2)
Select Field1, Field2
From Table2

NoviceMe
10-20-2004, 02:47 AM
Shurik12.

No I didn't, but will give it a go - thanks -I don't have the details in another table, I have a text file containing the rows to be inserted, so can the 'From' point to this instead?

Shurik12
10-20-2004, 03:19 AM
Well in this case you'll need to loop through through the text file
( first open an ADO recordset:
http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJetText)

and execute "INSERT INTO ..." against the connection object passing the recordset's fields as parameters.

Shurik.

NoviceMe
10-20-2004, 04:04 AM
Shurik12

now you have totally lost me, I am new to SQL, what is an ADO recordset?
and would I have one? Sorry If I am being dim here.

Shurik12
10-20-2004, 05:09 AM
>what is an ADO recordset?
it's merely a "virtual" table, if you wish, which doesn't physically exists. It's based on the "real", exisiting table(s) (or in your case- a text file). For more detailed infoplease have a look at the ADO Tutorial here:
http://www.xtremevbtalk.com/showthread.php?t=39722

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum