Lets say this is the situation:
[Stored Proc 1]
BEGIN
BEGIN TRANSACTION
...
exec sp 2
COMMIT
END
Now, if SP 2 – rolls back for whatever reason, does SP 1 – commit or rollback or throw exception?
Thanks.
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.
There are no autonomous transactions in SQL Server. You may see
@@TRANCOUNTincrease beyond 1, but a rollback affects the whole thing.EDIT asked to point to documentation. Don’t know of the topic that documents this explicitly, but I can show it to you in action.
Inner proc:
Outer proc:
So now let’s call it and let everything commit:
Results:
Now let’s call it and roll back the inner procedure:
Results: