views:

188

answers:

2

If I have the following SQL:

BEGIN TRANSACTION
SELECT val
FROM myTable

and don't follow it up with a commit, what happens with the TRANSACTION? Does it depend upon the context/scope that it was executed (e.g. in a proc, in mgt studio)?

Is there some place to see if there are transactions open that have not been committed/rolled back in a database?

Thanks,

Chris

+5  A: 

It stays open until the connection closes. When the connection is closed, the transaction is rolled back.

Current transactions can be seen in sys.dm_tran_active_transactions and sys.dm_tran_database_transactions.

Remus Rusanu
+1  A: 

Locks are not released for the objects used in the transaction and changes are only visible to that connection.

Ben S