How to Kill all Database Connections
May 15, 2018

The easiest way to kill all database connections is to set the database to SINGLE User mode;
ALTER DATABASE MyDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
then once finished, change this back to normal;
ALTER DATABASE MyDatabase SET MULTI_USER
The slightly more involved method is to use a scripted method to remove all connections to the DB;
Use Master Go Declare @dbname sysname Set @dbname = 'name of database you want to drop connections from' Declare @spid int Select @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname) While @spid Is Not Null Begin Execute ('Kill ' + @spid) Select @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname) and spid > @spid End