Terminate a connection (KILL)

更新时间:
复制 MD 格式

Use the KILL command to terminate an active user session on your ApsaraDB RDS for SQL Server instance. This is useful when a session is idle, blocking other queries, or consuming excessive resources.

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB RDS for SQL Server instance running SQL Server 2012 or later

Limitations

  • You can only close connections that you initiated. You cannot close other connections, such as backup connections.

Close a connection

  1. Query sys.dm_exec_sessions to list active user sessions and identify the Process ID to terminate:

    SELECT session_id, login_name, status
    FROM sys.dm_exec_sessions
    WHERE is_user_process = 1

    The session_id column contains the Process ID you need for the KILL command.

  2. Run KILL with the session_id from the query above:

    KILL <Process ID>

    For example, to terminate session 53:

    KILL 53