Using following query in my procedure I can count to connection to my database
SELECT
COUNT(dbid) as 'Total Connections'
FROM
master.dbo.sysprocesses WITH (nolock)
WHERE
dbid = 7
This is working fine, is there any way to get length of the every connection/session in minutes?
If you do this:
You will get the time difference between
login_time
and now in minutes, which I reckon is session time.BEWARE OF THIS:
From here: http://msdn.microsoft.com/en-us/library/ms189794.aspx
NOTE: You should be okay as you are asking for minutes connected which is not likely to overflow any time soon!