Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL Server View the number of connections

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Through management tools

Start-> manage tools-> performance (or enter mmc in the run) and then add the common statistics of SQL by adding counters and then select user connections in the items listed below to query the number of connections to the database from time to time. However, this method requires access to that computer, and you need to log in through your Windows account to add this counter.

two。 Query through system table

SELECT * FROM

[Master]. [dbo]. [SYSPROCESSES] WHERE [DBID] IN (SELECT

[DBID]

FROM

[Master]. [dbo]. [SYSDATABASES]

WHERE

NAME='DBName'

)

DBName is the database that needs to be viewed, and then the number of rows queried is the current number of connections. However, there are some other states that can be used as a reference.

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

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

Find out the connection records of all connections to the MyDatabase database.

Sysprocesses this table records connections to the SQL SERVER database.

3. Find through the system's stored procedures

SP_WHO 'UserName'

UserName is, of course, the user name that logs in to Sql. Generally, a UserName is used to log in to SQL so that you can see the connection occupied by this user name after logging in.

If you don't write UserName, then all connections are returned.

Select * from sys.dm_exec_connections

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report