Skip to content

docs of using transactions with sqlbulkcopy is internally contradictory #19953

Open
@ShahryarSaljoughi

Description

@ShahryarSaljoughi

Issue description
This document claims that Performing a Dedicated Bulk Copy Operation in a Transaction is similar to Performing a Non-transacted Bulk Copy Operation with one exception!

The problem is that they are no difference between them in terms of how they handle a failure.
According to docs, if no transaction is used:

All batches copied up to the point of the error are committed; the batch containing the duplicate key is rolled back, and the bulk copy operation is halted before processing any other batches. (quoted from the Performing a Non-transacted Bulk Copy Operation section)

and again according to docs, if UseInternalTransaction flag is used in order to perform a transacted bulk copy, the same behavior is happening:

l batches copied up to the point of the error are committed; the batch containing the duplicate key is rolled back, and the bulk copy operation is halted before processing any other batches. (quoted from the Performing a Dedicated Bulk Copy Operation in a Transaction section)

How are they different?

On the other hand the first paragraph of document says that:

The bulk copy operation occurs in a non-transacted way, with no opportunity for rolling it back.

and then suggests that if you need to rollback part of it, you need to use a transaction. In contrast of this, later in this article, it is stated that batches are executed in their own transaction, when we are "Performing a Non-transacted Bulk Copy Operation",and if a problem occurs the batch containing the problematic row will rollback!

Target framework

Check the .NET target framework(s) being used, and include the version number(s).

  • [ X] .NET Core
  • [X ] .NET Framework
  • .NET Standard

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions