Does SQL Server allow constraint violations in a transaction as long as it's not committed yet?

后端 未结 4 867
后悔当初
后悔当初 2020-12-14 15:00

Does SQL Server allow constraint violations (i.e. deferred constraints) in a transaction as long as the transaction has not been committed yet?

I ha

4条回答
  •  不知归路
    2020-12-14 15:37

    SQL Server does not have deferred contraints option. But in some cases you can use Bulk Insert that supports ignoring constraints without problems of disabling. For more information you can see these links:

    • Controlling Constraint Checking by Bulk Import Operations

    • BULK INSERT and INSERT: Using OPENROWSET and BULK to Bulk Load Data

    Then just before committing transaction, you will have to check the constraints on the whole table manually.

提交回复
热议问题