finding locked tables

  • I have a stand alone application that uses SQL Server 2005 . Sometimes, when we run the applications and follow a

    certain steps, the SQL server locks some of the table.

    How to find out the tables which are locked at that time?

  • sp_who2 - make a note of your process id

    sp_lock x (x = process id)

    This brings back a list of locks. Check the obj id's against sysobjects

    There is probably a quicker way I'm a bit old school in my methods

  • I'd take a look at the sys.dm_tran_locks dynamic management view. You could also use sys.dm_exec_requests to see which sessions are blocked, but just to see all locks, the first DMV is the way to go. You can combine DMV's to put together really interesting bits of data.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply