KILL (T-SQL)

Terminates a user process based on the system process ID (SPID). If the specified SPID has a lot of work to undo, the KILL may take some time to complete.
Syntax

KILL {spid}
Arguments

spid
Is the SPID of the process to terminate. The SPID value is a unique integer (smallint) assigned to each user connection when the connection is made, but the assignment is not permanent.

Remarks

KILL is commonly used to terminate a process that is blocking other important processes with locks, or to terminate a process that is executing a query that is using necessary system resources. System processes and processes running an extended stored procedure cannot be terminated.

Use KILL very carefully, especially when critical processes are running. You cannot kill your own process. Other processes not to kill are:

* AWAITING COMMAND
* CHECKPOINT SLEEP
* LAZY WRITER
* LOCK MONITOR
* SELECT
* SIGNAL HANDLER

Execute sp_who to get a report on valid SPID values. Use @@SPID to display the SPID value for the current session.
Permissions

KILL permissions default to the members of the sysadmin fixed database role, and are not transferable.
Examples

This example shows how to terminate SPID 10.

KILL 10

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *