MSSQL analysis of number of connections by LoginName and hostname

MS SQL analysis of number of connections by LoginName and hostname

When analyzing SQL server performance and usage a good place to start is by looking at the number of logins and from which server they are coming from. This is especially useful in a environment where there are multiple application components running on different servers such as large enterprise environments. This information gives you an insight into where to start looking for application elements that may be using SQL server resource inefficiently.

The query below presents a simple table that shows logins and from which device.

SELECT 
    DB_NAME(dbid) as DBName, 
	COUNT(dbid) as NumberOfConnections,
	loginame as LoginName,
	hostname  as hostname
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame,hostname
	order by hostname desc

Leave a Reply

Your email address will not be published. Required fields are marked *