Search This Blog

Friday, December 14, 2012

kill SQL Server

SQL Server > Transact-SQL > Kill

Terminates a user process that is based on the session ID.  

  • if the specified session has a lot of work to undo, the KILL statement may take some time to complete
  • KILL can be used to terminate a normal connection, which internally terminates the transactions that are associated with the specified session ID. 
  • can also be used to terminate orphaned and in-doubt distributed transactions when Microsoft Distributed Transaction Coordinator (MS DTC) is in use.


Example

exec sp_who

Results:
spid ecid status         loginame hostname    blk dbname                    cmd request_id
53   0       suspended sa            pc01            0    db                             DELETE 0

kill 53

Results:
Command(s) completed successfully.