KILL (Windows Azure SQL Database)
Terminates a user session in the current database that is based on the session ID. In Windows 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.
This syntax diagram demonstrates the supported arguments and options in Microsoft Windows Azure SQL Database. Windows 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
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.