可以用下面的SQL语句看看有没有阻塞、死锁,Sql server 是有阻塞问题,我原来的程序在Sql7 中没有问题,可是到了2000就阻塞,用这个查到了。解决的办法只能是换更好的服务起或整个重改表结构,和程序
use master
go
Declare @spid smallint,
@waitt int,
@waittime int --单位是毫秒,为已经阻塞的时间
set @waittime = 20000
Declare cblocked CURSOR For
Select spid ,waittime from sysprocesses where blocked = 0 and open_tran > 0
and spid in (select blocked from sysprocesses where blocked > 0 and waittime > @waittime)
Open cblocked
Fetch Next from cblocked Into @spid ,@waitt
While @@fetch_status = 0
Begin
print @spid
Fetch Next from Cblocked into @spid , @waitt
End
Close cblocked
Deallocate cblocked
--查看锁信息
select 进程id=req_spid
,数据库=db_name(rsc_dbid)
,类型=case rsc_type when 1 then 'NULL 资源(未使用)'
when 2 then '数据库'
when 3 then '文件'
when 4 then '索引'
when 5 then '表'
when 6 then '页'
when 7 then '键'
when 8 then '扩展盘区'
when 9 then 'RID(行 ID)'
when 10 then '应用程序'
end
,rsc_objid,rsc_indid
from master..syslockinfo