0

I am attempting to delete/drop a SQL Database created in from Azure Synapse Serverless Built-in Pool, but I keep on getting the error:

Error message: 'Failed to execute query. Error: Cannot drop database "" because it is currently in use. '. Tracking id: '3742517f-6b04-4b48-99e9-a1626d07ad8d'.

Any thoughts on why I'm getting error, and how to drop the database?

Now, when issue the following code:

USE [master];  
GO  
DROP  DATABASE [DataverseEnriched]; 
GO

I get the following output

enter image description here

Patterson
  • 1,927
  • 1
  • 19
  • 56

2 Answers2

0

[Azure Synapse Serverles Pool Database Error: Cannot drop database "DataverseEnriched" because it is currently in use]

  • I repro'd the same error in Serverless SQL pool. I created Database called Db1 and tried to drop database.

Failed to execute query. Error: Cannot drop database "Db1" because it is currently in use.

enter image description here

  • In order to drop database, use master. Below is the script.
USE [master];
GO 
DROP  DATABASE [Db1];
GO
Aswin
  • 4,090
  • 2
  • 4
  • 16
  • Hi @Aswin, thanks for reaching out. I tried your suggestion, however unfortunately I got the error ```A fatal scripting error occurred. Incorrect syntax was encountered while parsing GO.``` – Patterson Dec 20 '22 at 13:29
  • Could you share the screenshot of script and error message? – Aswin Dec 20 '22 at 13:35
  • Hi @Aswin, I'm now getting the output Cannot drop database "DataverseEnriched" because it is currently in use. I have updated the question showing the code producing the output – Patterson Dec 20 '22 at 13:39
  • Are you giving `GO` in the new line? – Aswin Dec 20 '22 at 13:41
  • I am giving GO, in the exact way you showed me.. see updated question – Patterson Dec 20 '22 at 13:42
  • Okay.. Are you not getting this error `A fatal scripting error occurred. Incorrect syntax was encountered while parsing GO.`? now – Aswin Dec 20 '22 at 13:43
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/250556/discussion-between-aswin-and-patterson). – Aswin Dec 20 '22 at 13:43
0

Are you trying it from the Synapose studio ?

--- Create the DB 
CREATE DATABASE TESTDB1
-- Run the below query and it will fails as the 
-- DB is already there 
CREATE DATABASE TESTDB1
---Error 
-- 12:22:47 PM
-- Started executing query at Line 5
-- Database 'TESTDB1' already exists.
 --  Choose a different database name.
-- Total execution time: 00:00:00.376
use master
go 
DROP DATABASE TESTDB1
-- Works fine 
-- Started executing query at Line 12
-- Changed database context to 'master'.
-- (0 record affected)

-- (0 record affected)

-- Total execution time: 00:00:00.401

Screenshot if that helps .

enter image description here

HimanshuSinha
  • 1,650
  • 2
  • 6
  • 10