Question

How to task kill the database connection through the cmd prompt

  • 13 February 2024
  • 1 reply
  • 28 views

Badge +2

How to task kill the database connection through the cmd prompt.


1 reply

Userlevel 5
Badge +11

Hi @Samadhan,

You can use the sqlcmd utility.

sqlcmd -S [server_name] -U [username] -P [password] -Q "KILL [spid]"

 

Replace [server_name] with your SQL Server name, [username] with your SQL Server username, [password] with your SQL Server password, and [spid] with the session ID (SPID) of the connection you want to terminate.

 

 

Reply