can some one let me know how to insert multiple rows in to a Table (using stored procedure)? I have C# code which should insert all the data into the table instead of calling the stored procedure (or insert) every time I haev to insert a row in to the table.
I have heard about user defined types/functions in sql to use cursor in order to insert multiple rows but I am not sure how to achieve this. Please let me know
Mark the post as answer if it was helpful to you. This solution might be useful for others too.
Then besides this way,I think you can also try to write a trigger——for insert,and then when you do something insert into another table,the related one will be also inserted。
For insert Trigger synax and some samples,maybe you can see this:
smithspd
Participant
1497 Points
463 Posts
How to Insert multiple rows into table
May 15, 2012 07:29 PM|LINK
folks,
can some one let me know how to insert multiple rows in to a Table (using stored procedure)? I have C# code which should insert all the data into the table instead of calling the stored procedure (or insert) every time I haev to insert a row in to the table. I have heard about user defined types/functions in sql to use cursor in order to insert multiple rows but I am not sure how to achieve this. Please let me know
sriramabi
Contributor
4351 Points
1277 Posts
Re: How to Insert multiple rows into table
May 15, 2012 07:44 PM|LINK
pls ref this
http://blog.sqlauthority.com/2008/07/02/sql-server-2008-insert-multiple-records-using-one-insert-statement-use-of-row-constructor/
http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/12/05/sql-server-2008-t-sql-insert-multiple-rows.aspx
http://stackoverflow.com/questions/5249913/sql-server-2008-trying-to-insert-multiple-rows-using-1-sql-statement
thank u
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to Insert multiple rows into table
May 17, 2012 01:48 AM|LINK
Hello:)
First you can have a good look at what
sriramabi
idea……
Then besides this way,I think you can also try to write a trigger——for insert,and then when you do something insert into another table,the related one will be also inserted。
For insert Trigger synax and some samples,maybe you can see this:
http://msdn.microsoft.com/en-us/library/aa258254(v=sql.80).aspx