How to view the current number of connections of the SQL Server database

Source: Internet
Author: User
1. Use Management Tools
Start-> Administrative Tools-> performance (or enter MMC in the running) then, you can add common SQL statistics by adding counters and select user connections in the projects listed below to query the number of database connections from time to time. However, this method requires the permission to access the computer, that is, you must log in to the Windows Account to add this counter.

2. query select * From through the system table
[Master]. [DBO]. [sysprocesses] Where [dbid] In (select
[Dbid]
From
[Master]. [DBO]. [sysdatabases]
Where
Name = 'dbname'
)

Dbname is the database to be viewed, and the number of queried rows is the current number of connections. However, there are some other statuses for reference.

For example, to connect to the master database, write the following statement

Select * From sysprocesses where dbid in (select dbid from sysdatabases where name = 'mydataba ')

Obtain all the connection records of the database connected to mydatabase.
The sysprocesses table records the connection to the SQL Server database.

3. search through the system's stored procedure

Sp_who 'username'

 

Username is the user name used to log on to SQL. Generally, a username is used in the program to log on to SQL. This user name can be used to check the connection occupied by this user name after login.
If username is not specified, all connections are returned.

 

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.