David Smith

David Smith

  • NA
  • 2k
  • 0

SQLBulkCopy

Mar 22 2012 1:05 PM
Can someone lead me to a good tutorial using SQLBulkCopy.

Basically i am importing data from a test file. Tell what would be the best approach. I am importing over a million into the database. Is SQLBulkCopy going to give the best performance. IF so can someone provide a tutorial how to successfully use SqlBulkCopy.

I am going to give you the structure I am using. I was planning on inserting into a temporary table first, then after I get the temporary table loaded I wanted to use the SQlBulkCopy to write the date to the SQL Server 2008. to the table below. can someone assist me.

I am going to create table in code with the same structure 

DataTable dt = new DataTable();

dt.Columns.Add(new DataColumn("ColorSerial", typeof(string)));
dt.Columns.Add(new DataColumn("ColorPart", typeof(string)));
dt.Columns.Add(new DataColumn("ColorDescription", typeof(string)));

 DataRow nextRow;

            nextRow = dt.NewRow();

            nextRow["ColorSerial"] = colorSerial;
            nextRow["ColorPart"] = colorPart;
            nextRow["ColorDescription"] = colorDescription;

Table Name: Color

Columns:      Color Serial, Color Part, Color Description,

Answers (8)