Sql Server如何查看被锁的表及解锁的方法
程序员文章站
2024-01-02 13:33:58
查看被锁表:
select spid
from master..sysprocesses
where db_name(dbid) = '数据库名称'
and...
查看被锁表:
select spid from master..sysprocesses where db_name(dbid) = '数据库名称' and spid <> @@spid and dbid <> 0
解除锁:
exec ('kill '+cast(@spid as varchar))
查看被锁表:
select request_session_id spid,object_name(resource_associated_entity_id) tablename from sys.dm_tran_locks where resource_type='object'
spid 锁表进程
tablename 被锁表名
解锁:
declare @spid int set @spid = 57 --锁表进程 declare @sql varchar(1000) set @sql='kill '+cast(@spid as varchar) exec(@sql)
以上所述是小编给大家介绍的sql server如何查看被锁的表及解锁的方法,希望对大家有所帮助