Reputation: 13840
I cannot drop custom databases in Azure Data Studio, because they are currently in use.
I've been looking for various ways to close the zap
database, but I cannot find any in the UI.
Only by restarting Azure Data Studio, is the zap
database in an "Auto Closed" state, which lets me drop it using:
drop database zap;
How do I close a connection to a database without restarting Azure Data Studio?
Upvotes: 21
Views: 28528
Reputation: 6514
You can try the following:
use master;
go
ALTER DATABASE zap SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Go
then drop database.
There is no need to find session which is connected to your database. it can be as simple as an object explorer open in another window. kill the session with the command above and then drop the database.
Upvotes: 4
Reputation: 95554
Someone else is connected, so you need to set it to SINGLE_USER
. This will terminate any existing connections, so that the database can be dropped.
USE master;
GO
ALTER DATABASE zap SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
DROP DATABASE zap;
GO
Upvotes: 67