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

0
=
0
+
0
No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.
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
=
0
=
$0
Internet users could send Bitcoin Tips to you if they like your answer!
  1. Close all active connections:

    ALTER DATABASE <DBName> set single_user with rollback immediate

  2. Drop your database:

    DROP DATABASE <DBName>

;)

SEND BITCOIN TIPS
0

Too many commands? Learning new syntax?

FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with FavScripts.com!

Post Answer