Solved

What happen if i forgot to give Commit transaction after begin trans?

Posted on 2012-03-30
3
1,802 Views
Last Modified: 2012-04-02
I update the table along with Begin trans in the sql Query window and forgot to give commit trans and close the Query window. Can you please tell what happens?

Begin trans
Update DBName..tablename set name ='xxx' where name='yyy'

1. The Specific database locked and no other user access the database/Table?
2. whatever updated rollback automatically
3, What happen if i open new sql query window and give commit transaction after 2 to 3 hours.
4. And how to find out if someone forgot to give commit transaction after Begin Trans.

Please clarify me. Thanks.
0
Comment
Question by:PKTG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Assisted Solution

by:rowansmith
rowansmith earned 140 total points
ID: 37785962
The default timeout is infinity.  You can change this by using SET LOCK_TIMEOUT

See: http://msdn.microsoft.com/en-us/library/ms189470.aspx

When your Client Disconnects, SQL Server will realize this has happened and will free the locks.

When you reconnect you are a new session, it is not possible commit a transaction in another session.  (There may be some "black-magic" way of finding an open transaction and forcing it to commit as an administrator, but I doubt very much it would be supported - you've got no way of knowing if the client finished its processing.

You can use SQL Enterprise Manager to view the current Locks.
0
 

Author Comment

by:PKTG
ID: 37787166
Thanks for the info. I understand below answer from you reply. Please correct me if i am wrong.

1. The Specific database locked and no other user access the database/Table?
--Create lock and it will affect user to access the db
2. whatever updated rollback automatically
--yes
3, What happen if i open new sql query window and give commit transaction after 2 to 3 hours.
-not able to commit
4. And how to find out if someone forgot to give commit transaction after Begin Trans.
--no way to find
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 180 total points
ID: 37787403
1. For an UPDATE on every row like that one,  the table would be locked and no other user could access the table, *expect* they can SELECT from the table using (NOLOCK) or the equivalent isolation level setting.
[No UPDATE ever locks out the whole db.]

2. No.  Rollback is not automatic by default.  By default the system will wait until you do either a commit or rollback.

3.  A new query window would be a different session, with its own separate transaction, and so would not affect the original trans one way or the other.

4. USE [database_name] DBCC OPENTRAN will show you the single oldest transaction.  You can also look at system views to find all locks being held and/or blocking occuring.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

631 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