February 9, 2012 at 3:37 am
How can query number of connection exists for particular period of time with sqlserver.
February 9, 2012 at 5:13 am
Simha24 (2/9/2012)
How can query number of connection exists for particular period of time with sqlserver.
Check the performance counter GeneralStatistcis:UserConnections for that particluar period.
February 9, 2012 at 7:09 am
will it right procedure for to get current login information
select ec.connection_id,es.session_id,es.login_time,es.host_name,es.status,es.prev_error,
er.request_id,er.session_id,er.transaction_id
from sys.dm_exec_connections ec INNER JOIN
sys.dm_exec_sessions es on ec.session_id = es.session_id join dm_exec_requests er
on er.connection_id=ec.connection_id where es.session_id>51
February 9, 2012 at 7:49 am
Don't rely on the fact that session_id > 51 means user process. It's undocumented and unreliable.
Try this instead:
SELECT *
FROM sys.dm_exec_sessions s
INNER JOIN sys.dm_exec_connections c
ON s.session_id = c.session_id
LEFT JOIN sys.dm_exec_requests r
ON r.connection_id = c.connection_id
WHERE s.is_user_process = 1
If you just want the count, use this:
SELECT COUNT(*)
FROM sys.dm_exec_sessions s
WHERE s.is_user_process = 1
Hope this helps
Gianluca
-- Gianluca Sartori
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply