I have deleted a database and trying to create one with same name but get already exists error

3P Tiqri Shaamil 0 Reputation points
2023-11-07T10:24:13.13+00:00

I have deleted a database in azure sql server. Now i am trying to create a database in the same name by copying from an existing database. But I keep getting an error saying a database with the same name exists. In the database listing it is not there. I can see my earlier database in the deleted databases list. Any idea how to solve this issue as i need to create the new database in the same name.
User's image

Azure SQL Database
SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,552 Reputation points Microsoft Employee Moderator
    2023-11-07T14:33:00.6433333+00:00

    Hi @3P Tiqri Shaamil Welcome to Microsoft Q&A thanks for posting your question.

    I understand that you are getting an error when copying from database as A database with the same name already exists on this server' and you can see in the portal the database has been deleted.

    I would suggest you can try renaming the database to a different name first and then changing it back to the original name after the import is done.

    You can try importing from portal or PowerShell to import database: PowerShell: Import a BACPAC file to a new database in Azure SQL Database - Azure SQL Database | Microsoft Learn

    New-AzSqlDatabaseImport (Az.Sql) | Microsoft Learn

    If the above steps don't resolve the issue, you can try contacting Azure support for assistance. They can help you troubleshoot the issue.

    Regards

    Geetha

    1 person found this answer helpful.
    0 comments No comments

  2. Alberto Morillo 34,676 Reputation points MVP Volunteer Moderator
    2023-11-07T15:48:16.5533333+00:00

    When you are creating the database as a copy of an existing database, create the database with a different name instead of using the old database name. Once you do that change the compute size and service tier of the newly created database to be the same as the old deleted database. After that you can change the name of the newly created database as the name of the deleted database using Transact-SQL ALTER DATABASE.

    ALTER DATABASE [ORIGINAL-NAME] MODIFY NAME = [RENAMED-NAME]
    
    
    

    It seems you posted the same question on StackOverflow. There I provided the same answer.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.