查詢目前連線數:
USE master
SELECT cntr_value AS User_Connections FROM sys.sysperfinfo AS sp
WHERE sp.object_name='SQLServer:General Statistics'
AND sp.counter_name='User Connections'
查詢目前連線明細:
USE master
SELECT c.session_id, c.connect_time, s.login_time, c.client_net_address, s.login_name, s.status
FROM sys.dm_exec_connections c left join sys.dm_exec_sessions s on c.session_id = s.session_id
Reference
sys.sysperfinfo
sys.dm_exec_connections
sys.dm_exec_sessions
沒有留言:
張貼留言