Rename an Azure SQL Database?

How can I rename a database in Azure sql?

I tried Alter database old_name {MODIFY NAME = new_name} but did not work.

Is this feature available in SQL Azure or not?

+70
tsql rename azure azure-sql-database
Oct 10 '11 at 10:14
source share
7 answers

Please check that you are connected to the main database and that you are not trying to rename the system database.

More information can be found here: https://msdn.microsoft.com/en-US/library/ms345378.aspx

+28
Oct 10 '11 at 10:17
source share

Just so people don’t have to look in the comments to find this ... Use:

 ALTER DATABASE [dbname] MODIFY NAME = [newdbname] 

(Make sure you include square brackets around both database names.)

+127
Feb 09 2018-12-12T00:
source share

You can also connect to SQL Server Management Studio and rename it to Object Explorer. I just did this, and the Cote d'Azur immediately reflected this change.

Do this by clicking on the database name (since the renaming option in the drop-down list will be grayed out)

+26
Jan 23 '15 at 1:43
source share

Connect to SQL Server Management Studio and the Azure database server, right-click the main database, and select New Query. In the window of a new query that opens the type ALTER DATABASE [dbname] MODIFY NAME = [newdbname] .

+7
Jun 18 '15 at 8:21
source share

It is very simple - connect to DB through SQL Management Studio and simply rename as usual for DB [press F2 on the DB name]. This will allow you to do this, and it will immediately reflect the same.

+5
Jan 27 '16 at 7:40
source share

I can confirm

 ALTER DATABASE [oldname] MODIFY NAME = [newname]; 

works without connecting to the wizard first, but if you rename the restored Azure database; don't miss the space before the final hyphen

 ALTER DATABASE [oldname_2017-04-23T09 -17Z] MODIFY NAME = [newname]; 

And get ready for the confusing error message in the Visual Studio 2017 message box when you execute the ALTER command

 Msg 0, Level 20, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. 
0
Apr 29 '17 at 8:02
source share

You can easily do this from SQL Server Management Studio, even from the public version.

0
Jul 03 '19 at 5:10
source share



All Articles