Find Locked Table in SQL Server


How can we find which table is locked in the database? Please, suggest.

By : user47957


You can use sp_lock (and sp_lock2), but in SQL Server 2005 onwards this is being deprecated in favour of querying sys.dm_tran_locks:

    object_name(p.object_id) as TableName, 
    resource_type, resource_description
    sys.dm_tran_locks l
    join sys.partitions p on l.resource_associated_entity_id = p.hobt_id


When reading sp_lock information, use the OBJECT_NAME( ) function to get the name of a table from its ID number, for example:

SELECT object_name(16003073)


There is another proc provided by microsoft which reports objects without the ID translation :

By : Learning

If you want data automatically updated on a schedule, look into cron (on Unix systems) or its equivalent. If you're using a commercial web host, they should have a way to schedule programs; otherwise, look into your own system's documentation for scheduling scripts.

Next, you want to write a script that downloads the weather information at that moment. Allow this script to translate from the "source" format to your own format.

Have the scheduler run your script once a day.

By : lacqui

This video can help you solving your question :)
By: admin