How to view the current number of SQL Server database connections

Source: Internet
Author: User
Tags sessions

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.