Kill all Processes in a Database
SQL Server 2000: Tested
SQL Server 2005: Tested
SQL Server 2008: Tested
SQL Server 2008R2: Tested
SQL Server 2012: Not Tested
Date: 16 May 2009
This SP iterates through all user processes in a database and kills them. The database is supplied as a parameter.
If no database is supplied, then the SP will exist with no action.
If you are calling the SP from a session connected to the target database then all connections except yours will be killed.
I could have screened out the current connection as well as the system connections, but the original use for this SP was when performing restores of a DEV environment (scheduled or immediate), and leaving it to fail for the current connection produced a more immediate error than the 30-second wait for a restore process to fail.