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 7653175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:57:44+00:00 2026-05-31T11:57:44+00:00

Lets say this is the situation: [Stored Proc 1] BEGIN BEGIN TRANSACTION … exec

  • 0

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.

  • 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-31T11:57:45+00:00Added an answer on May 31, 2026 at 11:57 am

    There are no autonomous transactions in SQL Server. You may see @@TRANCOUNT increase 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.

    USE tempdb;
    GO
    

    Inner proc:

    CREATE PROCEDURE dbo.sp2
        @trip BIT
    AS
    BEGIN
        SET NOCOUNT ON;
    
        BEGIN TRANSACTION;
    
        PRINT @@TRANCOUNT;
    
        IF @trip = 1
        BEGIN
            IF @@TRANCOUNT > 0
                ROLLBACK TRANSACTION;
        END
        ELSE
        BEGIN   
            IF @@TRANCOUNT > 0
                COMMIT TRANSACTION;
        END
    
        PRINT @@TRANCOUNT;
    END
    GO
    

    Outer proc:

    CREATE PROCEDURE dbo.sp1
        @trip BIT
    AS
    BEGIN
        SET NOCOUNT ON;
    
        BEGIN TRANSACTION;
    
        PRINT @@TRANCOUNT;
    
        BEGIN TRY
            EXEC dbo.sp2 @trip = @trip;
        END TRY
        BEGIN CATCH
            PRINT ERROR_MESSAGE();
        END CATCH
    
        PRINT @@TRANCOUNT;
    
        IF @@TRANCOUNT > 0
            COMMIT TRANSACTION;
    
        PRINT @@TRANCOUNT;
    END
    GO
    

    So now let’s call it and let everything commit:

    EXEC dbo.sp1 @trip = 0;
    

    Results:

    1
    2
    1
    1
    0

    Now let’s call it and roll back the inner procedure:

    EXEC dbo.sp1 @trip = 1;
    

    Results:

    1
    2
    0 <– notice that a rollback here rolled back both

    Transaction count after EXECUTE indicates a mismatching number
    of BEGIN and COMMIT statements. Previous count = 1, current count = 0.

    0
    0

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

Sidebar

Related Questions

I was wondering how exactly does TCP implement in-order delivery. lets say this is
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have this code: <?php class hello { var $greeting = hello;
Lets say i have this usercontrol public class test : UserControl { public int
Lets say I have this class in foobar-shared.lib: class FooBar { std::string m_helloWorld; }
Lets say we have this code: bool KeepGoing = true; DataInThread = new Thread(new
Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
I am trying to build a query which will do this: Lets say for
I'm not getting the syntax right. Lets say I have this... #include <set> ...
I'm trying to format a table from XML. Lets say I have this line

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.