Alex Rivera | Logout

What happens if you don't commit a transaction to a database (say, SQL Server)?

Asked 2011-02-04T09:36:43.433
150

Suppose I have a query:

begin tran
-- some other sql code

And then I forget to commit or roll back.

If another client tries to execute a query, what would happen?

Edit
Report

1 Answer

25

Transactions are intended to run completely or not at all. The only way to complete a transaction is to commit, any other way will result in a rollback.

Therefore, if you begin and then not commit, it will be rolled back on connection close (as the transaction was broken off without marking as complete).

answered 2011-02-04T09:41:10.603

Your Answer