Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 [RESOLVED] Check who has locks

Author  Topic 

dnig
Starting Member

8 Posts

Posted - 2010-01-12 : 07:04:27
Hey all,

Can anybody advise me of the sql command to list the locks on tables.
I can use sp_who to see the login_name and get the spid. I am then able to execute sp_lock with the spid to see what is locked.

My problem is the table name or object description isn't shown just the id code.

I'm written a small program that kicks this off overnight and emails me the results. I now need to see what is actually locked.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-12 : 07:13:06
did you try sp_lock

http://msdn.microsoft.com/en-us/library/ms187749.aspx
Go to Top of Page

dnig
Starting Member

8 Posts

Posted - 2010-01-12 : 07:21:34
quote:
I am then able to execute sp_lock with the spid to see what is locked.

My problem is the table name or object description isn't shown just the id code.



As above
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-12 : 07:32:17
quote:
Originally posted by dnig

quote:
I am then able to execute sp_lock with the spid to see what is locked.

My problem is the table name or object description isn't shown just the id code.



As above


it returns objid. you can use OBJECT_NAME() to get name of object from it.
http://msdn.microsoft.com/en-us/library/ms186301.aspx
Go to Top of Page

dnig
Starting Member

8 Posts

Posted - 2010-01-12 : 07:45:23
Is there any way to reference OBJECT_NAME whilst using sp_lock to simplify to 1 statement?
Go to Top of Page

dnig
Starting Member

8 Posts

Posted - 2010-01-12 : 08:24:44
Thanks for the point in the right direction visakh16. I have something that is workable now.
Go to Top of Page
   

- Advertisement -