Batch Insert

DavidE

New Member
Hi all,<BR><BR>Can someone please post or direct me to an example of how to do a batch insert into a DB. I'm grabbing the values from a multiple select box and what to insert the values into a DB all at once.<BR><BR>Thanks,<BR>D.you juse loop through each value and build a SQL string and insert<BR><BR><BR>whatever = split(request("SomeCrap"), ", ")<BR><BR>then loop through this array<BR>for <BR>sSQL = " Insert into (columns....) TableName value (......)"<BR>loop<BR><BR>execute(sSQl)<BR><BR>Hi,<BR><BR>I know you can loop through each item and insert into the DB, but there has to be a more efficient way -- only 1 call being made to the DB. If there are 20 items, that's 20 calls.<BR><BR>Thanks,<BR>D.i did not say loop through each item and insert<BR><BR><BR>i said loop through each item and BUILD A SQL STRING...look at my post again...see the for.....loop<BR><BR><BR>AFTER the loop you execute the string<BR><BR><BR>ONE trip.....MULTIPLE inserts<BR><BR><BR><BR><BR>you can pass that entire string to an SP and then parse it in the SP and insert<BR><BR><BR>Akhilesh... How do you do an sql insert statement to insert multiple rows? I thought insert was only for one row... would you seperate multiple insert statements by ;<BR><BR>? Sorry Ive wondered the same thing myself before.I was wondering the same thing too. The only way I know of doing it is:<BR><BR>INSERT INTO Table (Columns) SELECT Columns FROM Table WHERE etc.<BR><BR>But in this case, we're not grabbing the data from a table.
 
Back
Top