Search code examples
azure-sql-databaseazureportal

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


I have deleted a database in azure sql server via Azure Portal. 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. But 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.

enter image description here


Solution

  • 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]