MsSQL Server: How can I drop DB using T-SQL?


I want to drop my DB and close all connections before it

When I try to do it I receive this message:

Cannot drop database "DBName" because it is currently in use.


1 Answer

  1. Close all active connections:

    ALTER DATABASE <DBName> set single_user with rollback immediate

  2. Drop your database:




Too many commands? Learning new language? is a free tool that allows you to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your daily productivity with!

Post Answer