How to kill/Terminate all running process on Sql Server 2008

Buzz picture Buzz · Jun 11, 2012 · Viewed 62.3k times · Source

After executing this query on master db ,it is giving me all running process on all databases, is there any query which will kill all process running on a database .

USE
Master
GO

SELECT
SPID,DBID FROM SYSPROCESSES
WHERE
DBID NOT IN (1,2,3,4) AND SPID >50 AND SPID<> @@spid   

Answer

Damien_The_Unbeliever picture Damien_The_Unbeliever · Jun 11, 2012

If you want to force every other connection to disconnect, and you have suitable permissions, you can bounce the database in and out of single user mode:

alter database current set single_user with rollback immediate;
go
alter database current set multi_user;
go

Any other connection to the same database will be terminated.