Sqlserver 查询数据库连接数

 

sqlserver 查询监控数据库连接数sql脚本:  

SELECT  ec.client_net_address ,
        es.[program_name] ,
        es.[host_name] ,
        es.login_name ,
        COUNT(ec.session_id) AS [connection count]
FROM    sys.dm_exec_sessions AS es
        INNER JOIN sys.dm_exec_connections AS ec ON es.session_id = ec.session_id
GROUP BY ec.client_net_address ,
        es.[program_name] ,
        es.[host_name] ,
        es.login_name
ORDER BY ec.client_net_address ,
        es.[program_name];

 

posted on 2020-05-21 10:41  小呀么小二郎  阅读(702)  评论(0编辑  收藏  举报

导航