Is it possible to run multiple DDL statements inside a transaction (within SQL Server)?

后端 未结 4 565
南旧
南旧 2020-11-28 15:41

I\'m wondering if it is possible to run multiple DDL statements inside a transaction. I\'m specially interested on SQL Server, even though answers with other databases (Orac

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 16:14

    Could it be that in MS SQL, Implicit transactions are triggered when DDL and DML statements are run. If you toggle this off does this help, use SET IMPLICIT_TRANSACTIONS

    EDIT: another possibility - You can't combine CREATE VIEW with other statements in the same batch. CREATE TABLE is ok. You separate batches with GO.

    EDIT2: You CAN use multiple DDL in a transaction as long as separated with GO to create different batches.

提交回复
热议问题