Pages

Social Icons

Thursday 25 October 2012

Delete database forcefully


I am not sure how many times you might want to forcefully close all the active connections and drop a database. However, this is a very interesting question.

One option to do this is to take the database in SINGLE USER mode and then issue a DROP DATABASE command.

USE master;
GO
ALTER DATABASE dbname 
SET SINGLE_USER 
WITH ROLLBACK IMMEDIATE;
GO
DROP DATABASE dbname;

No comments:

Post a Comment