Overview
This topic describes how to view the connection and SQL statements that are run in RDS SQL Server.
Background information
Alibaba Cloud reminds you that:
- When you perform operations that have risks, such as modifying instance configurations or data, check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
- Before you modify the configurations and data of instances including but not limited to ECS and RDS instances, we recommend that you create snapshots or enable RDS log backup.
- If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.
View connections through the SYSPROCESSES system View
The Master.dbo.SYSPROCESSES view displays information about the running processes. Users can find all connections for a database in conjunction with Master.dbo.SYSDATABASES system view. The specific SQL is as follows.
SELECT * FROM
[Master].[dbo].[ SYSPROCESSES] WHERE [DBID] IN ( SELECT
[DBID]
FROM
[Master].[dbo].[ SYSDATABASES]
WHERE
NAME='[$DB_Name]'
)
Note:[$DB_Name] is the database name.
The following command output is displayed:
Use sp_who to view connection sessions and SQL
Syntax
- You can run the sp_who command to view all the connection sessions.
- To view the connection sessions of a user:
sp_who '[$User_Name]'
Note:[$User_Name] is the user name.
Application scope
- ApsaraDB RDS for SQL Server