SqlBulkCopy implements import of mass data and sqlbulkcopy

Source: Internet
Author: User

SqlBulkCopy implements import of mass data and sqlbulkcopy

// Regenerate the auto-increment column: SqlBulkCopy bc = new SqlBulkCopy (conn) // retain the original value of the auto-increment column: SqlBulkCopy bc = new SqlBulkCopy (conn, SqlBulkCopyOptions. keepIdentity) using (SqlBulkCopy sbc = new SqlBulkCopy (conn, SqlBulkCopyOptions. keepIdentity) {sbc. destinationTableName = tableName; foreach (string col in colList) {sbc. columnMappings. add (col, col);} sbc. bulkCopyTimeout = 0; sbc. writeToServer (dt );}

SqlBulkCopy adopts the BCP Protocol of SQL Server for Batch Data Replication. In combination with transactions, about 800 entries per batch is the balance point in our case, the performance is improved by more than 100 times than insert one by one, and the performance of the case with transaction batch insert is also improved by more than 7 times.

Personal Website: http://www.51pansou.com

. Net video download:. net video tutorial

. Net source code download:. net source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.