判断数据库死锁的Sql语句


sp_lock

 select  convert (smallint, req_spid) As spid,
  rsc_dbid As dbid,db.name as DBName,
  rsc_objid As ObjId,object_name(rsc_objid) as ObjectName,
  rsc_indid As IndId,
  substring (v.name, 1, 4) As Type,
  substring (rsc_text, 1, 16) as Resource,
  substring (u.name, 1, 8) As Mode,
  substring (x.name, 1, 5) As Status

 from  master.dbo.syslockinfo,
  master.dbo.spt_values v,
  master.dbo.spt_values x,
  master.dbo.spt_values u,
  master.dbo.sysdatabases db

 where   master.dbo.syslockinfo.rsc_type = v.number
   and v.type = 'LR'
   and master.dbo.syslockinfo.req_status = x.number
   and x.type = 'LS'
   and master.dbo.syslockinfo.req_mode + 1 = u.number
   and u.type = 'L' and db.dbid=rsc_dbid and rsc_objid>0
 order by spid

posted @ 2006-04-28 20:44  PointNet  阅读(1175)  评论(0编辑  收藏  举报