GeekArticles
Database
SQL Server
Database
SQL ServerUsing Transactions with SqlBulkCopy
<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 ></a></p>
Sponsored Links
Related Topics
Subscribe via RSS
SQL Server
- Naming Database Objects: Part II
- Trace Messages Part V: Trace Cleanup
- Naming Database Objects: Part I
- Multiple-Child Aggregation
- Creating SQL Tables for an Integrating Application Using Dexterity
- SQL Server 2005 Beta 2 Transact-SQL Enhancements
- .NET Rocks! - Brian Larson on SQL Server Reporting Services
- Computing the Trimmed Mean in SQL
- SQL Server 2000 Gains on Oracle
- Separator First Formatting (SFF)
