sql command "sp_who", which provides information about current users, sessions and processes in an instance of Microsoft SQL Server Database Engine ( MSDN ) Here you can send results to a temporary table and group them by server name.
for example, the following ...
CREATE TABLE #tbl ( spid int , ecid int , status varchar(50) , loginame varchar(255) , hostname varchar(255) , blk varchar(50) , dbname varchar(255) , cmd varchar(255) , request_id varchar(255) ) GO INSERT INTO #tbl EXEC sp_who SELECT COUNT(0), hostname FROM #tbl group by hostname DROP TABLE #tbl GO
Xabur source share