C# - Inserting multiple rows using a stored procedure

Posted by user177883 on Stack Overflow See other posts from Stack Overflow or by user177883
Published on 2010-05-19T14:09:29Z Indexed on 2010/05/19 14:20 UTC
Read the original article Hit count: 226

I have a list of objects, this list contains about 4 million objects. there is a stored proc that takes objects attributes as params , make some lookups and insert them into tables.

what s the most efficient way to insert this 4 million objects to db?

How i do :

-- connect to sql - SQLConnection ...

foreach(var item in listofobjects)
{    
   SQLCommand sc = ...

   // assign params

   sc.ExecuteQuery();    
}

THis has been really slow.

is there a better way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server