Question : Understanding sp_lock

In the output from sp_lock there is a column ObjId. My understanding is that this refers to the ID column in sysobjects for whatever database is refered to in the dbid column of the sp_lock output.

Is this correct?

If so, then what does an ObjId of 0 mean in the sp_lock output?

The Resource column of sp_lock refers to the particular page, exent etc that the lock is for, e.g. 1:23968. Is there any way of returning the actual rows that are in this resource?

Thanks in advance


Stephen

Answer : Understanding sp_lock

ObjId of 0 should mean that it doesn't apply to this lock: i.e., the lock is above (or below?) the level of an individual object in that db, or the type of object locked does not have an object id (is not in sysobjects).

The combination of Resource column and type will tell you how to interpret the Resource data.  From Books Online (topic "Displaying Locking Information"):

Resource type             Resource [Description]
RID   Row identifier of the locked row within the table. The row is identified by a fileid:page:rid combination, where rid is the row identifier on the page.
KEY   Hexadecimal number used internally by SQL Server.
PAG   Page number. The page is identified by a fileid:page combination, where fileid is the fileid in the sysfiles table, and page is the logical page number within that file.
EXT   First page number in the extent being locked. The page is identified by a fileid:page combination.
TAB   No information is provided because the ObjId column already contains the object ID of the table.
DB   No information is provided because the dbid column already contains the database ID of the database.
Random Solutions  
 
programming4us programming4us