Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Multiple insert

Author  Topic 

metser
Starting Member

27 Posts

Posted - 2006-11-02 : 04:20:11
Hello,

I have a web page where a user needs to select a number of items (1-100). He is then presented with a dynamically created form, with 8 columns and up to a 100 rows (according to the number of items he selected). He then proceeds to fill out the information on each of this rows, and submits the form. What I would like to do next is to INSERT the information to my DB. However, creating a loop which goes through each row and creates an Inserts the information to the DB seems problematic (CPU and connection wise)... is there any other way except coding the following on my ASP page:

'sample code
FOR EACH row IN form 'up to 100 rows!!
INSERT INTO tbl_Items (item_1, item_2 .... item_8)
VALUES ("form_field_1, form_field_2 .... form_field_8)
NEXT

Thank you

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-02 : 04:26:47
use SELECT ... UNION ALL

INSERT INTO tbl_Items (item_1, item_2 .... item_8)
select "form_field_1, form_field_2 .... form_field_8 union all
select ... union all
select ...



KH

Go to Top of Page
   

- Advertisement -