SQL SERVER – How to See Active SQL Server Connections For Database

Posted by Pinal Dave on SQL Authority See other posts from SQL Authority or by Pinal Dave
Published on Sun, 24 Aug 2014 01:30:19 +0000 Indexed on 2014/08/24 4:26 UTC
Read the original article Hit count: 1145

Another question received via email -

“How do I I know which user is connected to my database with how many connection?”

Here is the script which will give us answer to the question.

SELECT DB_NAME(dbid) AS DBName,
COUNT(dbid) AS NumberOfConnections,
loginame
FROM    sys.sysprocesses
GROUP BY dbid, loginame
ORDER BY DB_NAME(dbid)

Here is the resultset:

Reference: Pinal Dave (http://blog.SQLAuthority.com)


Filed under: PostADay, SQL, SQL Authority, SQL DMV, SQL Query, SQL Server, SQL Tips and Tricks, T SQL

© SQL Authority or respective owner

Related posts about PostADay

Related posts about sql