SQLServer查看用户连接数

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 

 

posted @ 2018-01-10 15:46  Vulper  阅读(969)  评论(0编辑  收藏  举报