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

Post Answer