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
自己试下
{{--
相关问答:
写了一个用C语言操作sqlserver数据库的程序,在我自己的计算机上运行没问题。但到另一台机器上运行时,SQLConnect函数连接数据库失败,仔细检查设置都没有发现问题,但该机器的操作系统是Windows Server 2003 Enterp ......
比如 用户名,我程序的要求是10位字符以内,所以:
如果我sqlserver从varchar(50)存储改为用varchar(10)的话,
1.会不会减少数据空间?
2.会不会提高我程序的效率?
3.有没有必要?
小弟先谢 ......
我想做一个触发器,但修改表T的字段C1时,判断如果修改后的值为-1,则更新表T该行记录的字段C2为某值。
CreateTRIGGER [Tri_UpdateLastSaveDate] ON [dbo].[T]
for UPDATE
AS
BEGIN ......
sqlserver有没有象oracle那样可以test存储过程 ,单步调试.不应该没有把,我怎么没找到呢? 要不然稍微长点的存储过程怎么调试呢?
好象没有.
没有吧
有,查询分析器中右键存储过程,单步调试
百度上去找一下 ......
我的数据库突然报一个很郁闷的错误,导致数据无法查看,
错误提示为:
在文件 'G:\data\企业管理数据库1_data.n ......