SQL Server: Quick way to find Active & idle connections on a SQL instance

Published 02 May 08 02:32 AM | SQL Master 

Using SQL Server 2005 you can take help of DMV - sys.dm_exec_connections that will give server-level information about the connections. In the olden days usage of sysprocesses system table used to be heavy and same approach can be achieved by using system DMVs within 2005 version onwards.

All these DMVs -  sys.dm_exec_connections, sys.dm_exec_sessions, and sys.dm_exec_requests dynamic management views map to the sys.sysprocesses system table. So if you have any adhoc code that used to get connections with active/idle then change it to use DMVs.

For the previous versions you can use:

select last_batch, datediff(mi,last_batch, getdate()) , spid, * from sys.sysprocesses

or

select spid from sys.sysprocesses  where ( datediff(mi,last_batch, getdate()) > 5)

Comments

# SQL Server Transact-SQL (SSQA.net) : SQL Server: Quick way to find Active & idle connections on a SQL instance said on May 2, 2008 3:01 AM:

PingBack from http://sqlserver-qa.net/blogs/t-sql/archive/2008/05/02/4138.aspx

# Other SQL Server Blogs around the Web said on May 2, 2008 5:51 AM:

Using SQL Server 2005 you can take help of DMV - sys.dm_exec_connections that will give server-level

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.