Skip to content

Cancel a user session / process in SQLServer Flex

Last updated on

Cancels a user process in SQLServer Flex that is based on the session ID.

Cancel the session / process with the stored procedure kill_sessions

Section titled “Cancel the session / process with the stored procedure kill_sessions”

With the following Stored Procedure you will be able to cancel a user process / session for:

  • a database (currently only user databases are considered) - When specified, cancel all SPIDs inside of the database.

exec [msdb].[STACKIT].[kill_sessions] @database_name = ‘dbname

  • a user name - When specified, cancels all SPIDs under the login name.

exec [msdb].[STACKIT].[kill_sessions] @login_name = ‘loginname

  • a session ID - When specified, cancels the selected SPID.

exec [msdb].[STACKIT].[kill_sessions] @sID = number

Only users with the following database roles can run the Stored Procedure.

  • ##STACKIT_ProcessManager##
  • ##STACKIT_ServerManager##