To check active database connection in the MS SQL server please follow the below steps.

Step 1: Open the SQL server management studio. Please refer to how to connect MsSQL DB using SQL management studio.

Step 2: Right-click on the database and click on the New Query option.

Step 3: In the Query window, enter the below select query to find an active connection on your database. After then, click on the Execute button to run the query.

SELECT DB_NAME(dbid) AS DBName,
COUNT(dbid) AS NumberOfConnections,
loginame
FROM sys.sysprocesses
GROUP BY dbid, loginame
ORDER BY DB_NAME(dbid)

Note: Replace the DBName with your database name. 

You will see a result in the below screen capture; it will show all the active database connections on your SQL server.

To check the active sessions/connection in the SQL server execute the below query in the SQL server management studio.

exec sp_who

The above query will show all the active users and sessions connected to the SQL server.

That's all.

Hai trovato utile questa risposta? 44 Utenti hanno trovato utile questa risposta (62 Voti)