View the connection of the currently connected database

Source: Internet
Author: User

1. Check the system performance:
Start-> Administrative Tools-> performance (or enter MMC in the running) and then
Add counters, add common SQL statistics, and select user connection in the items listed below.
The number of connections to the database has been queried.
However, this method requires the permission to access the computer, that is, to log in through a Windows account.
To add this counter.

2. query through the system table:
Select * from
[Master]. [DBO]. [sysprocesses] Where [dbid] In (select
[Dbid]
From
[Master]. [DBO]. [sysdatabases]
Where
Name = 'databasename'
)
Databasename 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:

Connect to the master database
Write the following statement:

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

Obtain all connection records of the database ichaoshi1.

The sysprocesses table records the connection to the SQL Server database.

 

3. query through the system process:
Sp_who 'loginname'
Loginname is the username used to log on to SQL.ProgramIt uses a username to log on to the SQL
We can see the connection occupied by this user name after login.
If you do not enter loginname, all connections are returned.
 

 

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.