Msg 6115, Level 16, State 1, Line 1
KILL command cannot be used inside user transactions.
This error message appears when you try to use the KILL command inside a user transaction.
The T-SQL statement can be parsed, but causes the error at runtime.
Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must remove the explicit transaction.
All versions of SQL Server.
DECLARE @i INT
DECLARE @stmt NVARCHAR(100)
SELECT @i = @@SPID
SET @stmt = ‘KILL ‘ + CAST(@i AS NVARCHAR(2))
EXECUTE sp_ExecuteSQL @stmt
In the above example we try to terminate the current session inside a user transaction. This raises the error.