SqlServer中详细了解锁表并激活

原创
小哥 3年前 (2022-11-16) 阅读数 43 #大杂烩
--查看锁表:
select   request_session_id   spid,OBJECT_NAME(resource_associated_entity_id) tableName  
from   sys.dm_tran_locks where resource_type=OBJECT

--解锁:
declare @spid  int
Set @spid  = 200 --锁表进程
declare @sql varchar(1000)
set @sql=kill +cast(@spid  as varchar)
exec(@sql)

执行查看锁表可以看到,当前有一张表被锁,spid为200,如果要解锁就把查到的spid给解锁中的变量@spid,执行解锁即可。

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门