SQL SERVER query lock table and unlock

View the locked table:
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName 
from sys.dm_tran_locks where resource_type='OBJECT' 
spid lock table process 
tableName locked table name

Unlock:
declare @spid int 
Set @spid = 57 --lock table process
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)

 

Sometimes, the logged-in user will be locked, which can be unlocked by the following predictions

alter login sa enable; 

alter login sa with password ='Cmdi1002'; 

 

go

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326174353&siteId=291194637