select convert(varchar(30),suser_sname(p.sid)) as 用户名,<br> convert(smallint,req_spid) as 事务进程ID,<br> convert(varchar(30),db_name(rsc_dbid)) as 数据库名,<br> case rsc_dbid when db_id()<br> then convert(varchar(30),object_name(rsc_objid))<br> else convert(varchar(30),rsc_objid) end as 持有锁的资源id,<br> rsc_indid as 持有锁的表索引id,<br> substring (lock_type.name,1,4) as 资源持有的锁类型,<br> substring (lock_mode.name,1,12) as 事务请求的锁类型,<br> substring (lock_status.name,1,5) as 请求的当前状态,<br> substring (rsc_text,1,16) as 资源内部名称<br> from master..syslockinfo s<br> join master..spt_values lock_type on s.rsc_type=lock_type.number<br> join master..spt_values lock_status on s.req_status=lock_status.number<br> join master..spt_values lock_mode on s.req_mode=lock_mode.number-1<br> join master..sysprocesses p on s.req_spid=p.spid<br> where lock_type.type='LR'<br> and lock_status.type='LS'<br> and lock_mode.type='L'<br> and db_name(rsc_dbid) not in ('master','msdb','tempdb','model')<br>order by spid,lock_type.number<br><br>或用<br>exec sp_who