Process ID %d is not an active process ID

Error Message:
Msg 6106, Level 16, State 1, Line 1
Process ID %d is not an active process ID.

Severity level:
16.

Description:
This error message appears when you try to terminate a inactive process via the KILL command.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. Only active user-processes can be terminated via KILL

Versions:
All versions of SQL Server

Example(s):
CREATE TABLE #t
(
 spid INT NULL
 , ecid INT NULL
 , status SYSNAME NULL
 , loginname SYSNAME NULL
 , hostname SYSNAME NULL
 , blk INT NULL
 , dbname SYSNAME NULL
 , cmd NVARCHAR(1000) NULL
 , request_id INT NULL
)
INSERT INTO #t EXEC sp_who
DECLARE @max_spid INT
DECLARE @stmt NVARCHAR(100)
SELECT @max_spid = MAX(spid)
  FROM #t
SET @stmt = ‘KILL ‘ + CAST(@max_spid +1 AS NVARCHAR(10))
EXEC sp_ExecuteSQL @stmt
DROP TABLE #t

Remarks:
In the above example the results from sp_who is piped to a temporary table. The MAX(spid) value is incremented by 1 to ensure that the resulting value really represents an unknown and therefore inactive process-ID. Because such a process-ID cannot be terminated via KILL, the error is raised.

]]>

Leave a comment

Your email address will not be published.