Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
Assembly: System.Data (in System.Data.dll)
A batch is complete whenrows have been processed or there are no more rows to send to the destination data source.
Zero (the default) indicates that each WriteToServer operation is a single batch.
If the SqlBulkCopy instance has been declared without the UseInternalTransaction option in effect, rows are sent to the server rows at a time, but no transaction-related action is taken. If UseInternalTransaction is in effect, each batch of rows is inserted as a separate transaction.
The following console application demonstrates how to bulk load data in batches of 50 rows. For an example illustrating how Transaction and Bulk Copy Operations.works with a transaction, see
In this example, the source data is first read from a SQL Server table to a SqlDataReader instance. The source data does not have to be located on SQL Server; you can use any data source that can be read to an IDataReader or loaded to a DataTable.
This sample will not run unless you have created the work tables as described in Bulk Copy Example Setup. This code is provided to demonstrate the syntax for using SqlBulkCopy only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL INSERT … SELECT statement to copy the data.
Available since 2.0