Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-30
3
Medium Priority
?
2,040 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
3 Comments
 
LVL 11

Assisted Solution

by:rowansmith
rowansmith earned 560 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 70

Accepted Solution

by:
Scott Pletcher earned 720 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

824 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