开发者

TSQL: comma combination, transaction?

Given the following:

select * from a; 
select * from b;

Are these two statements run in an implicit开发者_StackOverflow transaction?


The default transaction mode in SQL Server is autocommit, unless you specify otherwise. This means that every statement is run in its own transaction; if one fails, all of the preceding statements still succeed.

You can change this with either a BEGIN TRAN statement (explicit transaction) or SET IMPLICIT_TRANSACTIONS ON (turns on implicit transactions). Note that if you enable implicit transactions, only the BEGIN is implicit - you still need to explicitly COMMIT.

It's also generally considered bad practice to use implicit transactions; it tends to lead to buggier scripts due to transactional boundaries not being clearly visible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜