Sunday, 23 July 2017

How to Kill a SPID in SQL Server?

If you are a DBA or database developer, you would have encountered a lot of blocking scenarios. Blockings are nothing but clash between two session IDs. A session is nothing but a transaction like insert, update or delete for a particular process, which is assigned in the form of SPID in SQL server.

Further, when we come across a situation to kill a session or SPID in SQL server that means we are trying to stop the transaction. But before killing the SPID, to see the sessions running currently could be viewed using the command as:

EXEC SP_WHO2 ACTIVE


To kill the session in a particular database, use the below command:

USE <database_name>
GO
KILL <SPID_Number>

        Example: Kill 278

0 comments: