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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:15:33+00:00 2026-05-27T20:15:33+00:00

In sql server 2008, I am using a pattern like this: begin transaction begin

  • 0

In sql server 2008, I am using a pattern like this:

begin transaction

begin try

/* do something */

end try

begin catch

if @@TRANCOUNT > 0
rollback

 DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int                              
  SELECT @ErrMsg = ERROR_MESSAGE(),                              
         @ErrSeverity = ERROR_SEVERITY()                              

  RAISERROR(@ErrMsg, @ErrSeverity,1)     

end catch

if @@TRANCOUNT > 0
commit transaction

when I hit “Cancel Executing Query” button on Sql Server Management Studio it cancels the query and leaves the transaction open.

Is this the intended behavior? Or is there a mistake in my pattern. Shouldn’t it rollback the transaction?

  • 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-27T20:15:34+00:00Added an answer on May 27, 2026 at 8:15 pm

    IMHO, it is an intended behavior. When you cancels query running if there was open transaction – it remains open until you explicitly commit or roll it back OR until connection is not closed

    There is no any valuable mistakes in your pattern. If you control execution flow manually (Cancel Executing Query), then you should care of opened transactions in the same manner – manually.

    Update:

    The behavior is controlled by SSMS option Disconnect after the query executes – which means that the query disconnects after execution or cancel and rolls back opened transactions:
    enter image description here

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

Sidebar

Related Questions

i am updating a sql server 2008 database using c# like this: foreach (DataRow
I'm using SQL Server 2008 and I would like to use a sproc to
I'm developing an ASP.NET app (C#) that connect to SQL Server 2008 using ADO.NET
I am looking to manage a SQL Server 2008 DB using Management Studio 2005.
I am using VSTS 2008 + C# + ADO.Net + SQL Server 2008. My
I am using VSTS 2008 + C# + .Net 3.5 + SQL Server 2008
Using SQL Server 2008, is there a way to allow inserts to a table
I'm using SQL Server 2008 with Advanced Services on my Vista Home Premium. I'd
I'm using SQL Server 2008 Management studio viewing a 2005 server and have just
I'm using SQL Server 2008. My database is almost 2GB in size. 90% of

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.