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

0

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.

Thanks..

1 Answer

  1. Close all active connections:

    ALTER DATABASE <DBName> set single_user with rollback immediate

  2. Drop your database:

    DROP DATABASE <DBName>

;)

0

Too many commands? Learning new language?

FavScripts.com 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 FavScripts.com!

Post Answer