kill

Description

Kills a process.

Syntax

kill spid with statusonly

Parameters

spid

is the identification number of the process you want to kill. spid must be a constant; it cannot be passed as a parameter to a stored procedure or used as a local variable. Use sp_who to see a list of processes and other information.

with statusonly

reports on the progress of a server process ID (spid) in rollback status. It does not terminate the spid. The statusonly report displays the percent of rollback completed and the estimated length of time in seconds before the rollback completes.

Examples

Example 1

Kills process number 1378:

kill 1378

Example 2

Reports on the process of the rollback of spid number 13:

kill 13 with statusonly
spid: 13 Transaction rollback in progress. Estimated rollback completion:17%
Estimated time left: 13 seconds

To track the progress of a rollback, you must run kill...with statusonly multiple times. If the rollback of the spid has completed when you issue kill...statusonly or if Adaptive Server is not rolling back the specified spid, kill...statusonly returns the following message:

Status report cannot be obtained. KILL spid:nn is not
in progress.

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for kill differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled, you must have the kill privilege to kill you own process, and have the kill any process privilege to kill another user's processes.

Granular permissions disabled

With granular permissions disabled, you must be a user with sa_role.

kill privilege is not transferable.

See also

Commands shutdown

System procedures sp_lock, sp_who