sql server 解锁, 查看数据库链接数
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 = 60 --锁表进程
DECLARE @sql VARCHAR(1000)
SET @sql='kill '+CAST(@spid AS VARCHAR)
EXEC(@sql)
--链接数
SELECT
COUNT(dbid) as NumberOfConnections
FROM
sys.sysprocesses
WHERE
dbid > 0