Search

Saturday, July 30, 2011

Kill all spids

If you dont want to restart a whole instance but want to kill all spids for a specific database run this code:

alter database quotareports set single_user with rollback immediate
go
alter database quotareports set multi_user with rollback immediate

It will rollback whats present and removes all spids except the one that is running the code. The second part will set the database in default status and ready for new connections.

This code can also be used when you need to restore a database and you have to be the only one in the database.

No comments:

Post a Comment