Export (0) Print
Expand All

KILL (Azure SQL Database)

This topic is OBSOLETE. You can find the most current version in the SQL 14 Transact-SQL Reference.

ImportantImportant
This topic is not maintained. For the current version, see KILL (Transact-SQL).

Terminates a user session in the current database that is based on the session ID. In Microsoft Azure SQL Database, the KILL statement can only be used to terminate sessions of the database the user is logged into. If the specified session ID has a lot of work to undo, the KILL statement may take some time to complete, particularly when it involves rolling back a long transaction.

Syntax Conventions (Azure SQL Database)


KILL { session ID } [ WITH STATUSONLY ] 

This syntax diagram demonstrates the supported arguments and options in Microsoft Microsoft Azure SQL Database. Microsoft Azure SQL Database does not support the UOW (unit of work) argument when using the KILL statement.

session ID
Is the session ID of the process to terminate. session ID is a unique integer (int) that identifies a session in the database the user is connected to.The session ID value is tied to the connection for the duration of the connection. When the connection ends, the value is released and can be reassigned to a new connection.

WITH STATUSONLY
Generates a progress report about a specified session ID that is being rolled back due to an earlier KILL statement. KILL WITH STATUSONLY does not terminate or roll back the session ID; the command only displays the current progress of the rollback.

For more information about the arguments and the KILL statement, see KILL (Transact-SQL) in SQL Server Books Online.

Requires the KILL DATABASE CONNECTION permission. This permission is implied by the CONTROL database permission and the ALTER ANY CONNECTION server permission.

A. Using KILL to terminate a session

The following example shows how to terminate session ID 53.

KILL 53;

B. Using KILL session ID WITH STATUSONLY to obtain a progress report

The following example generates a status of the rollback process for the specific session ID.

KILL 54;
KILL 54 WITH STATUSONLY;
GO

--This is the progress report.
spid 54: Transaction rollback in progress. Estimated rollback completion: 80% Estimated time left: 10 seconds.

Community Additions

ADD
Show:
© 2014 Microsoft