Solved

What happens if if No Commit or Rollback called on SQLTransaction??

Posted on 2008-06-19
6
413 Views
Last Modified: 2013-11-06
I have a C# Application which makes use of SqlConnection and SqlCommand objects with a Transaction set by calling BeginTransaction.

Now what happens say if the application is in the middle of Executing the Command and then abnormally ends (power failure, whatever) so without calling Commit (or Rollback).

So the Connection obviously terminates, what happens to the Transaction? Does it auto rollback when a connection terminates?

Your speedy response is appreciated.

Thanks!
0
Comment
Question by:Mokwaja
6 Comments
 
LVL 19

Expert Comment

by:bevhost
ID: 21821991
Surely if it doesn't commit, then it's not a permanent addition.
0
 
LVL 17

Expert Comment

by:dbaSQL
ID: 21822056
under normal circumstances, I believe the entire transaction is terminated and a rollback will occur
i'm not certain, but if the application goes down, the tran may remain open as sql is waiting for it to finish, possibly blocking other processes until that happens.  

0
 
LVL 17

Accepted Solution

by:
dbaSQL earned 500 total points
ID: 21822071
yes.  the tran will close if you commit, rollback, exit... or the app crashes
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Mokwaja
ID: 21822081
Yes, but what happens to te Transaction? Does SQL Roll it back? What state is it in then if no Commit or Rollback was called from the app?
0
 

Author Comment

by:Mokwaja
ID: 21822099
Ok, thanks for the comments!
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21822129
If it's not committed and the connection drops, it's rolled back.

But if you can, you still want to roll it back yourself.  Transactions cause locking and it may take sql server some time to notice a connection was dropped before it can rollback.  That means the locks are held for a little longer, which is bad.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now