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 connections by LoginName 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

We also have a great article on SQL Server Efficiency which is a great guide on understanding where you can look for efficiencies and ultimately increase performance in addition to looking for the number of connections by LoginName.

Other posts you might be interested in