Click here to Skip to main content
15,914,384 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I want to perform the following in Sql server 2005 .
1 Connect to the Current database
2 Run though the whole database and find if there are any active transaction
3 Collect all the transaction that are active
4 Kill - Rollback all the transactions
5 Which table the lock is applied?
6 Who is the user that the lock is done by


Kindly suggest a Solution .
Thanks in advance .
Posted
Updated 14-Dec-10 19:41pm
v3

1 solution

Thank you for your question. You can check active transaction in a database by the following SQL Statement that syntax is.

SQL
DBCC OPENTRAN
[
    ( [ database_name | database_id | 0 ] ) ]
    { [ WITH TABLERESULTS ]
      [ , [ NO_INFOMSGS ] ]
    }
]


You will get SPID (server process ID). Then use Kill to terminate it.

SQL
KILL { session ID | UOW } [ WITH STATUSONLY ]



Thanks,
Mamun
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900