Is there any way to get a full total record count from SqlBulkCopy?

Viewed 63

The SqlBulkCopy class has a reporting mechanism built in: the SqlRowsCopied event. Every NotifyAfter records, it fires this event and gives you a running total of how many rows have been copied so far.

This is great, as long as your total number of rows is an exact multiple of the NotifyAfter property. But if it's not, you get an inaccurate count. In the worst case scenario, where your total number of rows is less than the NotifyAfter property, your total gets reported as 0!

Is there any way to get an accurate count out of this class, without having to either resort to a separate query as the doc page does or set NotifyAfter to 1 and slow the copying to a crawl?

0 Answers
Related