Login to SQL Management Studio, select Master database and click on New Query and paste the below code :
CREATE TABLE #sp_who2
(SPID INT,
Status VARCHAR(1000) NULL,
Login SYSNAME NULL,
HostName SYSNAME NULL,
BlkBy SYSNAME NULL,
DBName SYSNAME NULL,
Command VARCHAR(1000) NULL,
CPUTime INT NULL,
DiskIO INT NULL,
LastBatch VARCHAR(1000) NULL,
ProgramName VARCHAR(1000) NULL,
SPID2 INT,
RequestID INT)
GO
INSERT INTO #sp_who2
EXEC sp_who2
GO
SELECT Login, DBName, count(Login) AS Connections
FROM #sp_who2
GROUP BY Login, DBName
ORDER BY Connections DESC
GO
DROP TABLE #sp_who2
GO
(SPID INT,
Status VARCHAR(1000) NULL,
Login SYSNAME NULL,
HostName SYSNAME NULL,
BlkBy SYSNAME NULL,
DBName SYSNAME NULL,
Command VARCHAR(1000) NULL,
CPUTime INT NULL,
DiskIO INT NULL,
LastBatch VARCHAR(1000) NULL,
ProgramName VARCHAR(1000) NULL,
SPID2 INT,
RequestID INT)
GO
INSERT INTO #sp_who2
EXEC sp_who2
GO
SELECT Login, DBName, count(Login) AS Connections
FROM #sp_who2
GROUP BY Login, DBName
ORDER BY Connections DESC
GO
DROP TABLE #sp_who2
GO
Click on Execute button, and it will show the current connections to the SQL database server.
That’s it…
COMMENTS