国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

查看死鎖的存儲過程

2024-07-21 02:47:44
字體:
來源:轉載
供稿:網(wǎng)友
查看死鎖的存儲過程 Posted on 2015-02-06 09:40 哈爾濱計算機磚家 閱讀(...) 評論(...) 編輯 收藏
CREATE PRocedure sp_who_lock   as    begin        declare @spid int       declare @blk int       declare @count int       declare @index int       declare @lock tinyint         set @lock=0        create table #temp_who_lock       (        id int identity(1,1),        spid int,        blk int     )       if @@error<>0 return @@error       insert into #temp_who_lock(spid,blk)       select 0 ,blocked        from (select * from master..sysprocesses where blocked>0)a       where not exists(select * from  master..sysprocesses where a.blocked =spid and blocked>0)       union select spid,blocked from  master..sysprocesses where blocked>0      if @@error<>0 return @@error       select @count=count(*),@index=1 from #temp_who_lock       if @@error<>0 return @@error       if @count=0      begin       select '沒有阻塞和死鎖信息'      return 0      end      while @index<=@count       begin       if exists(select 1 from #temp_who_lock a where id>@index and exists(select 1 from #temp_who_lock where id<=@index and a.blk=spid))        begin        set @lock=1        select @spid=spid,@blk=blk from #temp_who_lock where id=@index        select '引起數(shù)據(jù)庫死鎖的是: '+ CAST(@spid AS VARCHAR(10)) + '進程號,其執(zhí)行的SQL語法如下'       select  @spid, @blk       dbcc inputbuffer(@spid)         dbcc inputbuffer(@blk)        end       set @index=@index+1      end      if @lock=0       begin       set @index=1       while @index<=@count        begin        select @spid=spid,@blk=blk from #temp_who_lock where id=@index        if @spid=0         select '引起阻塞的是:'+cast(@blk as varchar(10))+ '進程號,其執(zhí)行的SQL語法如下'       else         select '進程號SPID:'+ CAST(@spid AS VARCHAR(10))+ '被' + '進程號SPID:'+ CAST(@blk AS VARCHAR(10)) +'阻塞,其當前進程執(zhí)行的SQL語法如下'   dbcc inputbuffer(@spid)       dbcc inputbuffer(@blk)         set @index=@index+1       end      end      drop table #temp_who_lock       return 0     end                 GO


上一篇:SQL索引

下一篇:內存中 OLTP

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 当阳市| 新竹市| 东辽县| 高密市| 华坪县| 左贡县| 塔河县| 宁都县| 太仓市| 淮安市| 石台县| 新田县| 织金县| 西乡县| 顺义区| 孙吴县| 延长县| 瓮安县| 汉源县| 郓城县| 广灵县| 舒兰市| 林芝县| 珲春市| 彩票| 安顺市| 和硕县| 保康县| 贵南县| 望江县| 常德市| 日照市| 华池县| 曲周县| 银川市| 泉州市| 泾阳县| 柳林县| 东安县| 西峡县| 承德县|