Dheeraj
Dheeraj

Reputation: 337

Script to Delete Azure SQL Database if serverName is Null

We have some solutionDB(lets say solution100) that stuck in the creating state so the serverName would be NULL, I have to delete the solutionDB if the ServerName is null.

So first I have to get the list of SQL databases and server names, iterate through the list, and then delete the solutionDB if the serverName is NULL.

Upvotes: 1

Views: 131

Answers (1)

Jack Zeng
Jack Zeng

Reputation: 2267

From what you describe, I guess that you are creating an SQL Database with a new SQL Server. But, the creation is stuck at server level, which means the SQL server has not been created yet. There is no server, so there is no database yet at all. Hence, there is nothing you can delete.

Now, the only thing you need to do is to figure out at what step the creation is stuck.

Here are some hints for you.

  1. Log into the new Portal, click Browse at the left navigation of the page.

    enter image description here

  2. Enter Audit Logs to search. And then, click Audit Logs

  3. Click filter, and choose the resource group of your SQL Database to narrow your search.

    enter image description here

  4. Now, you will be able to see a column with operation Update SQL database. Click it, and you will be able to see what's wrong with your SQL database creation.

Upvotes: 3

Related Questions