Given the following:
select * from a;
select * from b;
Are these two statements run in an implicit transaction?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 TRANstatement (explicit transaction) orSET IMPLICIT_TRANSACTIONS ON(turns on implicit transactions). Note that if you enable implicit transactions, only theBEGINis implicit – you still need to explicitlyCOMMIT.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.