Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

DB Connection Killer

By Miguel Pereira-543757,

This script opens a little cursor that will clean out connections to any DBs you specify. It will release SPIDs that are active on a DB or which are locking a related SPID. I found the base script some time ago -I wish I remembered the author or location- but I've modified it ever so slightly to provide for a good package that can be used prior to starting a DB restore for example.

Feel free to play with it and adapt it to whatever needs you may have. I've used this, at times, to kill SPIDs which were causing blocking conditions. You should be able to easily modify it to go after very specific conditions.

Total article views: 1340 | Views in the last 30 days: 2

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones