How to determine total number of open/active connections in ms sql server 2005

前端 未结 8 2349
再見小時候
再見小時候 2020-11-27 09:06

My PHP/MS Sql Server 2005/win 2003 Application occasionally becomes very unresponsive, the memory/cpu usage does not spike. If i try to open any new connection from sql man

8条回答
  •  自闭症患者
    2020-11-27 09:57

    I know this is old, but thought it would be a good idea to update. If an accurate count is needed, then column ECID should probably be filtered as well. A SPID with parallel threads can show up multiple times in sysprocesses and filtering ECID=0 will return the primary thread for each SPID.

    SELECT 
        DB_NAME(dbid) as DBName, 
        COUNT(dbid) as NumberOfConnections,
        loginame as LoginName
    FROM
        sys.sysprocesses with (nolock)
    WHERE 
        dbid > 0
        and ecid=0
    GROUP BY 
        dbid, loginame
    

提交回复
热议问题