Tech Tutorials Database
GeekArticles Database SQL Server
 

Using Transactions with SqlBulkCopy

 
Author: 4guysfromrolla.com
Category: SQL Server
Comments (0)

<p> The <a class</a> provides a mechanism for efficiently importing large amounts of data into a Microsoft SQL Server database. Compared to importing data by executing one <code>INSERT</code> statement for each record to import, <code>SqlBulkCopy</code> is noticeably faster when importing thousands (or more) records. In a nutshell, importing data using <code>SqlBulkCopy</code> entails creating a <code>SqlBulkCopy</code> object, specifying the destination database and table, and providing the data to import in the form of a <code>DataTable</code>, <code>DataRow</code>, or DataReader. In <a SqlBulkCopy To Perform Efficient Bulk SQL Operations</a> we looked at how to use <code>SqlBulkCopy</code> to programmatically import data from an uploaded Excel spreadsheet into a SQL Server database. </p><p> While <i>Using SqlBulkCopy To Perform Efficient Bulk SQL Operations</i> showed how to use the <code>SqlBulkCopy</code> class, it did not explore how <code>SqlBulkCopy</code> imports fare in the face of an error. What happens if, when importing a total of 10,000 records, an error occurs when importing record number 501? Should those first 500 records be committed or should the entire batch be rolled back? This article examines the default behavior of the <code>SqlBulkCopy</code> class in the face of an error. It also looks at how to perform bulk copy operations under the umbrella of a <a Read on to learn more! </p><p><i><b>Note:</b> If you have not yet read <a SqlBulkCopy To Perform Efficient Bulk SQL Operations</a>, please do so before reading this article...</i><br /><a More &gt;</a></p>

Read More...




Sponsored Links




Read Next: An Extensive Examination of LINQ: Introducing LINQ to XML



 

 

Comments



Post Your Comment:

Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe