SQL Server: Kill All the SPIDs

Sometimes, we need to take a SQL Server database offline. After notifying the users and giving them plenty of warning, they leave connections to the database – some connections are SLEEPING or AWAITING COMMAND, others have select statements that have been running for over four hours. I use the following sql to kill off all of the remaining user sessions on a database. Just change the YOURDATABASE text to the name of your database and […]