查看死锁 的存储过程 ,工具存储过程 sp_who_lock
http://blog.sina.com.cn/s/blog_95b5eb8c010162jp.html
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_who_lock]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_who_lock]
GO
go
create procedure sp_who_lock
as
begin
declare @spid int,@bl int,
@intTransactionCountOnEntry int,
@intRowcount int,
@intCountProperties int,
@intCounter int
create table #tmp_lock_who (
id int identity(1,1),
spid smallint,
bl smallint)
IF @@ERROR<>0 RETURN @@ERROR
insert into #tmp_lock_who(spid,bl) select 0 ,blocked
from (select * from sysprocesses where blocked>0 ) a
where not exists(select * from (select * from sysprocesses where blocked>0 ) b
where a.blocked=spid)
union select spid,blocked from sysprocesses where blocked>0
IF @@ERROR<>0 RETURN @@ERROR
-- 找到临时表的记录数
select @intCountProperties = Count(*),@intCounter = 1
from #tmp_lock_who
IF @@ERROR<>0 RETURN @@ERROR
if @intCountProperties=0
select '现在没有阻塞和死锁信息' as message
-- 循环开始
while @intCounter <= @intCountProperties
begin
-- 取第一条记录
select @spid = spid,@bl = bl
from #tmp_lock_who where Id = @intCounter
begin
if @spid =0
select '引起数据库死锁的是: '+ CAST(@bl AS VARCHAR(10)) + '进程号,其执行的SQL语法如下'
else
select '进程号SPID:'+ CAST(@spid AS VARCHAR(10))+ '被' + '进程号SPID:'+ CAST(@bl AS VARCHAR(10)) +'阻塞,其当前进程执行的SQL语法如下'
DBCC INPUTBUFFER (@bl )
end
-- 循环指针下移
set @intCounter = @intCounter + 1
end
drop table #tmp_lock_who
return 0
end
查看死锁 的存储过程 ,工具存储过程 sp_who_lock的更多相关文章
- ORACLE 检索某列包含特定字符串的数据表工具存储过程
使用示例: delete APPS.FIND_RESULT; set serveroutput ondeclare v_ret varchar(200);begin apps.sp_f ...
- sqlserver查看死锁进程工具脚本p_lockinfo
/* -- 处理死锁 -- 查看当前进程,或死锁进程,并能自动杀掉死进程 -- 因为是针对死的,所以如果有死锁进程,只能查看死锁进程 -- 当然,你可以通过参数控制,不管有没有死锁,都只查看死锁进程 ...
- SQL查看死锁+清理死锁
----查看sql死锁 CREATE procedure sp_who_lock as begin declare @spid int declare ...
- SqlServer 查看死锁的进程
版权声明:本文为 走错路的程序员 原创文章,欢迎转载. https://blog.csdn.net/phker/article/details/78612974搞sqlsever 好多年, 从来没锁过 ...
- Java如何查看死锁
Java中当我们的开发涉及到多线程的时候,这个时候就很容易遇到死锁问题,刚开始遇到死锁问题的时候,我们很容易觉得莫名其妙,而且定位问题也很困难. 因为涉及到java多线程的时候,有的问题会特别复杂,而 ...
- Java如何查看死锁?
转载自 https://blog.csdn.net/u014039577/article/details/52351626 Java中当我们的开发涉及到多线程的时候,这个时候就很容易遇到死锁问题,刚开 ...
- SQLServer查看死锁
SQLServer查看死锁 if exists ( select * from sys.procedures where name like '%USP_ShowLocks%' ) drop proc ...
- SQL Server 2008 存储过程,带事务的存储过程(创建存储过程,删除存储过程,修改存储过
SQL Server 2008 存储过程,带事务的存储过程(创建存储过程,删除存储过程,修改存储过 存储过程 创建存储过程 use pubs --pubs为数据库 go create proc ...
- svn的差异查看器和合并工具换成BCompare.exe
svn的差异查看器和合并工具换成BCompare.exe
随机推荐
- Spring @Scheduled应用解析
最近,遇到的一个需求,需要执行定时任务,每个一定时间需要执行某个方法 因为项目是SpringMVC的项目,所以使用的是Spring @Scheduled(由于quartz应用起来太麻烦,所以没有采用) ...
- Android斗地主棋牌游戏牌桌实现源码下载
本次给大家分享下Android斗地主棋牌游戏牌桌实现源码下载如下: 为了节约内存资源,每张扑克牌都是剪切形成的,当然这也是当前编程的主流方法. 1.主Activity package com.biso ...
- POM
代码的第一行是xml头,指定了该xml文档的版本和编码方式 project是所有pom.xml的根元素,还声明了一些POM相关的命名空间及xsd元素. modelVersion指定了当前POM模型的版 ...
- CentOS 7 网络配置工具
之前在CentOS 6下编辑网卡,直接使用setup工具就可以了. 但在新版的CentOS 7里,setuptool已经没有网络编辑组件了,取而代之的是NetworkManager Text User ...
- JavaScript:substr vs substring vs slice
参考文章: JavaScript取子串方法slice,substr,substring对比表
- web api 初体验 解决js调用跨域问题
跨域界定 常见跨域: 同IP不同端口: http:IP:8001/api/user http:IP:8002/api/user 不同IP不同端口: http://172.28.20.100:8 ...
- zenefits oa - sort integer array in lexographical order
[ 12 | 2434 | 23 | 1 | 654 | 222 | 56 | 100000 ] Then the output should be: [ 1 | 100000 | 12 | 222 ...
- Android上传图片到服务器
一.android需要导入异步请求的jar包 AsyncHttpClient public static void reg(final Context cont,Bitmap photodata,S ...
- Isostorespy 数据库无法打开的解决方案
重装Sql Server Compact http://download.microsoft.com/download/0/9/D/09D6ECB6-7F46-4B93-BB45-586A30A778 ...
- CSS3 实现3D旋转木马效果
基本原理: 1.首先我们需要让图片能旋转的效果,我们让所有图片绝对定位(position:absolute),共用一个中心点. 2.对于舞台我们加一个视距,比如下面的demo是 perspective ...