SQL Server- To See Number of Connections from Each Server Connecting to the Database

SELECT​​ DB_NAME(dbid)​​ AS​​ DBName,

 ​​ ​​ ​​ ​​ ​​ ​​​​ COUNT(dbid) ​​ ​​​​ AS​​ NumberOfConnections,

 ​​ ​​ ​​ ​​ ​​ ​​​​ loginame  ​​ ​​ ​​ ​​​​ AS​​ LoginName,

 ​​ ​​ ​​ ​​ ​​ ​​​​ nt_domain  ​​ ​​ ​​​​ AS​​ NT_Domain,

 ​​ ​​ ​​ ​​ ​​ ​​​​ nt_username  ​​​​ AS​​ NT_UserName,

 ​​ ​​ ​​ ​​ ​​ ​​​​ hostname  ​​ ​​ ​​ ​​​​ AS​​ HostName

FROM ​​ ​​​​ sys.sysprocesses

WHERE ​​​​ dbid​​ >​​ 0

GROUP ​​​​ BY​​ dbid,

 ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ hostname,

 ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ loginame,

 ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ nt_domain,

 ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ nt_username

ORDER ​​​​ BY​​ NumberOfConnections​​ DESC;

 

 

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Bookmark the permalink.

Leave a Reply

Leave a Reply

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