August 31st, 2011, 08:49 AM
INSERT multiple records at the same time
I want to insert several records at the same time from a form (asp/Ms SQL)
I have in this form a list of football players and checkboxes in order to choose if they have played or not.
So when form is submitted it have to store in a table, idplayers and idmatch value (hidden form value).
That could be used to list players by match
How can i do it?
I ve made an asp page listing the players with player's id ans check box for each player to choose or not.
Thanks a lot
August 31st, 2011, 03:07 PM
Start by visiting the documentation for the INSERT command for your db, which will show you how you need to write the SQL for the insert.
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
August 31st, 2011, 06:06 PM
Insert multiple rows in single query using TSQL
To insert multiple rows with the help of single query you can use following syntax:
( col1, col2, ... coln )
( '21', 9, ... 'oh' )
,( '22', 37, ... 'my' )
,( '23', 42, ... 'we' )
,( '24', 11, ... 'be' )
,( '25', 77, ... 'at' );
INSERT INTO Table1 (FirstColumn, SecondColumn)
SELECT 'First' ,1
SELECT 'Second' ,2
SELECT 'Third' ,3
SELECT 'Fourth' ,4
SELECT 'Fifth' ,5
September 17th, 2011, 12:44 AM
Hai, you can use sqlbulkcopy class in asp.net to insert multiple values.