none
Inserting millions of rows into a table RRS feed

  • Question

  • Hi,

    I have a DataTable in memory and I want to write a C# code to dump the data into a SQL database. Is there a faster way of dumping millions of rows into a SQL table besides running INSERT INTO row by row?

    Thank you,

    Jina

    Thursday, August 10, 2006 9:32 PM

Answers

  • If you are using .NET 2.0 then you can use the new SqlBulkCopy Class. I am not sure though if it supports inserting into older versions of SQL Server but it will work against SQL Server 2005. Else it is best to dump the rows to a file and then use BCP/BULK INSERT/OPENROWSET(BULK)/DTS/SSIS.
    Thursday, August 10, 2006 11:40 PM

All replies

  • Use BCP for Bulk insert
    Thursday, August 10, 2006 10:39 PM
  • If you are using .NET 2.0 then you can use the new SqlBulkCopy Class. I am not sure though if it supports inserting into older versions of SQL Server but it will work against SQL Server 2005. Else it is best to dump the rows to a file and then use BCP/BULK INSERT/OPENROWSET(BULK)/DTS/SSIS.
    Thursday, August 10, 2006 11:40 PM