sqlserver 数据库死锁后多长时间解锁?
各位大侠,sqlserver 数据库死锁后,会不会自动解锁呢?多长时间能自动解锁呢?谢谢!
SQL code:
use master
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
自己试下
{{--
相关问答:
代码:
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con= DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost: ......
在SqlServer中如何查看历史上执行的存储过程的信息呢,如:传入参数,执行时间等等。如果不能查看历史记录,是否可以自己写触发器之类的,人工控制呢,在Oracle里面有动态视图可以随时查看历史执行的sql语句,SqlSer ......
sqlserver 占用内存太高怎么解决?
sqlserver 2000 sp4,xp 系统,我自己的机子是开发机,占用内存太高了,机子反应慢,请问有没针对开发的配置,让sqlserver在后台跑起来的时候占用内存稍微小一点。如果有应 ......
用sqlserver 2000 agent 生成一个job,改job里面有调用一个应用程序,该应用程序会去调打印机打印
单独跑这个应用程序调打印机是正确的, 然后用sqlserver 2005里的agent去调也是可以正常打印的。。 ......
1.
select top 20 id,title,PageUrl from Infor
where title like '以德配天,明德慎%' order by id desc
CPU 时间 = 0 毫秒,占用时间 = 39 毫秒。
2.
select top 20 id,title,PageUrl ......