SELECT * FROM sys.sysprocesses -check process
SELECT * FROM Sys.sysusers ----Check user related information
Select * FROM Sys.dm_exec_connections--this command can see the connection condition
--This command can see how many sessions, one connection can have multiple sessions
Select session_id,status,login_name,login_time,* from sys.dm_exec_sessions
Select sql_handle,* from sys.dm_exec_requests-The ID of the request, the status of the request. Such as:
Background. The request is a background thread, such as a resource monitor or deadlock monitor.
is running. The request is running.
can be run. The request is running, and due to the lack of arbitration, a proper arrangement should be made on a temporary basis.
Sleep. There's no work to do.
Hangs. The request is waiting for a worker thread to pick.
is suspended. The request is waiting for an event.
Finally, we use the table above to select the table we need to connect to the desired results.
Select Db_name (database_id) dbname,login_name,t1.session_id,
T1.request_id,t2.status,t1.start_time, HOST_NAME
From sys.dm_exec_requests T1
INNER JOIN sys.dm_exec_sessions T2
On t1.session_id=t2.session_id
How to view the current number of SQL Server database connections