Skip to content

Instantly share code, notes, and snippets.

@nickfloyd
Created October 31, 2013 16:32
Show Gist options
  • Save nickfloyd/7252767 to your computer and use it in GitHub Desktop.
Save nickfloyd/7252767 to your computer and use it in GitHub Desktop.
SQL that returns number of connections per database grouped by login
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sys.sysprocesses
WHERE
dbid > 0
GROUP BY
dbid, loginame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment