查看最大连接数
csharp
SELECT @@MAX_CONNECTIONS
查看指定数据库的连接数
csharp
SELECT * FROM master.dbo.sysprocesses WHERE dbid IN
(
SELECT dbid FROM master.dbo.sysdatabases
WHERE NAME='DB_WMS_KZJ'
)
获取当前SQL服务器所有的连接详细信息
csharp
SELECT * FROM sysprocesses
获取自上次启动 SQL Server服务 以来连接或试图连接的次数
csharp
SELECT @@CONNECTIONS
查看连接数
csharp
select hostname 主机名,count(*) 连接数量 from master.dbo.sysprocesses group by hostname order by count(*) desc
或者
csharp
SELECT login_name,
Count(0) user_count
FROM Sys.dm_exec_requests dr WITH(nolock)
RIGHT OUTER JOIN Sys.dm_exec_sessions ds WITH(nolock)
ON dr.session_id = ds.session_id
RIGHT OUTER JOIN Sys.dm_exec_connections dc WITH(nolock)
ON ds.session_id = dc.session_id
WHERE ds.session_id > 50
GROUP BY login_name
ORDER BY user_count DESC
参考:
https://m.656463.com/wenda/rhcxSQLSERVERzljcdzdljs6496_77
https://blog.csdn.net/w13511069150/article/details/115396501