Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlBulkCopy.BulkCopyTimeout property

I am using VSTS 2008 + C# + .Net 3.5 + ADO.Net to develop a console application to do bulk insert copy.

I want to use both bulk insert batch and bulk insert timeout property. For the BulkCopyTimeout property, I am confused and want to know whether it applies for the whole bulk or applies to only each batch of the bulk?

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.bulkcopytimeout.aspx

thanks in advance, George

like image 975
George2 Avatar asked Sep 27 '09 10:09

George2


People also ask

What is the use of SqlBulkCopy?

The SqlBulkCopy class can be used to write data only to SQL Server tables. However, the data source is not limited to SQL Server; any data source can be used, as long as the data can be loaded to a DataTable instance or read with a IDataReader instance.

What is SqlBulkCopy in C#?

Bulk means many things. So with the use of SqlBulkCopy you can send a large amount of data from any source to SQL Server database. For example you have a collection of data in XML format and you want to save this data into your database table. You can do this very easily.

Does SqlBulkCopy use transaction?

By default, a bulk copy operation is its own transaction. When you want to perform a dedicated bulk copy operation, create a new instance of SqlBulkCopy with a connection string, or use an existing SqlConnection object without an active transaction.

What is Batchsize in SqlBulkCopy?

Copies all rows from a data source to a destination table specified by the DestinationTableName property of the SqlBulkCopy object.


1 Answers

Searching and reading some blog postings and forum posts on the web appears to indicate the the SqlBulkCopyTimeout actually does apply not to the entire operation, but to each batch in the operation.

The MSDN docs isn't totally clear on this, but most posts seem to indicate that the timeout applies to the batch. Decreasing the batch size and/or increasing the SqlBulkCopyTimeout seems to be the solution to timeout problems in most cases.

See this forum post as an example.

Marc

like image 161
marc_s Avatar answered Nov 03 '22 12:11

marc_s