Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see SQL 2008 Locks and Blocked Tables

During the ASP.NET execution of my app, it seems SQL 2008 Express holds some lock, and I get

Timeout expired.  The timeout period elapsed prior to completion of

the operation or the server is not responding

Maybe some of my query is not optimized. Visual Studio crashes with:

Microsoft Visual Studio may be unstable now. It is recommended that

you save all files and exit.

I need to see what query is blocking my tables, but I have the Express version. How can I do?

Thanks

like image 931
Robert Avatar asked May 25 '09 11:05

Robert


2 Answers

You can query against the sys.dm_tran_locks dynamic view to obtain this information. Go here on MSDN to lean more.

like image 147
Matt Spradley Avatar answered Oct 06 '22 00:10

Matt Spradley


exec sp_lock

and

exec sp_who2
like image 35
Jeff Meatball Yang Avatar answered Oct 06 '22 00:10

Jeff Meatball Yang