Search code examples
sybasesap-ase

find locks on a table with specifc row sybase


the below query will give me the lock on a table

select distinct object_name(id)
from master..syslocks 

what I am searching is to find out on which row its locking ?

for example if I got update messages set name ='hi' where id =1 and messages is causing locks, I want a query to know that id =1 for this table is causing locking. can I know that ?


Solution

  • First it depends if you table is using AllPages/Datapages/Datarows lock scheme (see output of "sp_help tablename")

    If it is Datarows, you can get a lock on specific row, otherwise locks will be on page (data or index or both) or on the table. Using syslocks or sp_lock, you can retrieve the page involved in the lock. To print the content of the page, you could run "dbcc page (database_id,pageno,4)"