Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7193125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:06:21+00:00 2026-05-28T20:06:21+00:00

I put transactions in all my set procedures. No problems. Everything works. In this

  • 0

I put transactions in all my “set” procedures. No problems. Everything works.

In this case, I need one set procedure, to call another, thankfully, only once, or that would potentially complicate things further.

So the happy bath would be.

  • I’m in ProcA and start a transaction.
  • It calls ProcB and it starts a transaction.
  • ProcB is successful and commits.
  • ProcA is successful and commits.

However, what happens if ProcB fails, rollsback, and rethrows the error. It should cause ProcA to rollback as well correct?

What if ProcB succeeds, commits, then ProcA subsequently fails, and rollsback…will what happened in ProcB be rolled back? or is it commited?

I need these two to work together, either both succeed, or fail and both be rolled back. What’s the best way to ensure this happens?

I’m working with Microsoft SQL Server 2008 R2 (SP1)

Note: If ProcB requires a transaction because it can be called without ProcA wrapping it. And technically, ProcA won’t always call ProcB (depends on input).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:06:22+00:00Added an answer on May 28, 2026 at 8:06 pm

    Here’s a simple demo to show what happens with nested transations:

    CREATE TABLE TranTest (Field1 INTEGER)
    
    BEGIN TRANSACTION
    SELECT @@TRANCOUNT -- 1 open transaction
    INSERT TranTest VALUES (1)
    
        BEGIN TRANSACTION
        SELECT @@TRANCOUNT -- 2 open transactions
        INSERT TranTest VALUES (2)
        ROLLBACK TRANSACTION -- this rolls back ALL transaction
    
    SELECT @@TRANCOUNT -- 0 open transactions (you may have expected 1?)
    SELECT * FROM TranTest -- No rows
    

    Instead f the ROLLBACK above, if you did a COMMIT TRANSACTION, this actual does nothing other then decrement @@TRANCOUNT. So you then would need to to either COMMIT the outer transaction (which would COMMIT both rows to the table), or do a ROLLBACK which would result in no rows being committed to the table.

    Here’s the MSDN ref on nested transactions: http://msdn.microsoft.com/en-us/library/ms189336.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Put them all in one separate folder structure or along with classes which implements
We have a website, where transactions are entered in and put through a workflow.
Put it another way: what code have you written that cannot fail. I'm interested
We put all of our unit tests in their own projects. We find that
I wrote a stored procedure that restores as set of the database backups. It
I'm trying to set up a relationship as follows. Each Master item has one
edit: Ok, to put this in a question, I'm asking for possible ways I
I need to generate a Deterministic Finite Automata (DFA), selected from all possible DFAs
Would it add overhead to put a DB transactions around every single service method
I am using Spring's declarative transactions (the @Transactional annotation) in aspectj mode. It works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.