|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:09 AM
Points: 169,
Visits: 276
|
|
there is a stored procedure with the following code
Begin transaciton --update =56 -----lots of select code in between no DML select =56 ----- lots of select code in between no DML --commit transaction
The update statement and commit was commented as part of some changes to the procedure but they forgot to comment the begin transaciton. this procedure is being called many times without any failures.
Question: what will be the impact due to this proc which has only begin tran with only select statements and NO DML and NO commit tran
subban
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:11 PM
Points: 1,776,
Visits: 1,438
|
|
| Above transaction will result in Deadlocks. This current SPID will allways be in a running state until commited or killed.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:15 PM
Points: 37,651,
Visits: 29,903
|
|
The transactions will never be committed, the locks those updates take will be held until the connection is closed. When the connection is closed, because there has been no commit statement issued, SQL will roll back all changes.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:15 PM
Points: 37,651,
Visits: 29,903
|
|
Mayank Khatri (4/8/2009) Above transaction will result in Deadlocks. Why do you say that? Locks and blocking it will definitely cause, but with only one update, it's unlikely to deadlock, unless there's more to it than we've been shown.
This current SPID will allways be in a running state until commited or killed. Actually not. Once the last of the selects has finished, the state of the connection will be sleeping. Only connections that are currently running queries have a running state. A connection can be sleeping with open transactions.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:11 PM
Points: 1,776,
Visits: 1,438
|
|
| Transaction cane be commited if u use commit tran on the same SPID or client that had started executing your T-SQL queries. (i.e. same window)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097,
Visits: 2,157
|
|
Subhash (4/8/2009)
Question: what will be the impact due to this proc which has only begin tran with only select statements and NO DML and NO commit tran
and also will bloat your Tlog file.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:09 AM
Points: 169,
Visits: 276
|
|
As the code didn't display properly updating it correct as below
Begin transaciton --update tablename set column2=1 where column1=56 -----lots of select code in between no DML select * from tablename where column1=56 ----- lots of select code in between no DML --commit transaction
There is no update and no commit, all it does is a begin tran and a select. (the reason i put the update and commit commented because it was there in the procedure before and commented later but the developer forgot to comment the begin tran.
Having said the above, what will happen if there is a BEGIN TRAN and followed by a SELECT without commit.
I have observed no Opentran due to this
subban
|
|
|
|