Technology Encyclopedia Home >How to view the current connection and the SQL executed by TencentDB for SQL Server?

How to view the current connection and the SQL executed by TencentDB for SQL Server?

To view the current connections and the SQL statements executed in TencentDB for SQL Server, you can use the following methods:

  1. Using SQL Server Management Studio (SSMS):

    • Connect to your TencentDB for SQL Server instance via SSMS.
    • To check current connections, run the query:
      SELECT * FROM sys.dm_exec_connections;
      
    • To view active SQL statements being executed, run:
      SELECT 
          r.session_id, 
          r.status, 
          r.command, 
          t.text AS [SQL Text], 
          r.start_time, 
          r.cpu_time, 
          r.reads, 
          r.writes 
      FROM 
          sys.dm_exec_requests r 
      CROSS APPLY 
          sys.dm_exec_sql_text(r.sql_handle) t;
      
  2. Using TencentDB for SQL Server Console (Built-in Tools):

    • Log in to the Tencent Cloud Console.
    • Navigate to TencentDB for SQL Server under the database section.
    • Select your instance and go to the Monitoring & Logs or Database Management tab.
    • Some instances provide a Performance Insight or SQL Audit feature to view active connections and executed SQL statements.
  3. Using Tencent Cloud's Database Audit Service (if enabled):

    • If you have enabled Database Audit, you can view historical SQL execution logs, including connection details and query statements.
    • Access the audit logs via the Tencent Cloud Console under Database Audit in the TencentDB for SQL Server section.

For advanced monitoring, TencentDB for SQL Server supports integration with Cloud Monitor, which provides metrics like connection count, query latency, and resource usage. You can configure alerts for abnormal connection spikes or long-running queries.