
Sometimes, you might have the requirement to rename the Azure SQL database. In this article, we will discuss how to rename the Azure SQL database and along with that, we will also discuss a few other topics as mentioned below.
Table of Contents
How to rename Azure SQL database
Before, starting the actual functionality, you should know the prerequisites needed here to perform this operation.
Prerequisites
- You must Download and install Azure Data Studio.
- You must have an Azure Account or Azure Subscription. If you don’t have one, you can create an Azure Free account now.
- Install the updated version of Microsoft SQL Server Management Studio.
Assuming you are ready with all the prerequisites needed here, let’s start with the actual functionality.
Well, you can rename the Azure SQL database using Azure Data Studio and Microsoft SQL Server, etc. Now let’s discuss them one by one.
- Approach-1: Using Azure Data Studio
- Approach-2: Using SQL Server
- Approach-3: Rename Azure SQL database PowerShell
Approach-1: Using Azure Data Studio
You can quickly rename the Azure SQL database using Azure Data Studio by following the below steps.
- First, connect Azure Data Studio to Azure SQL.
- Once you are connected to Azure SQL database, Double click on the Database node or expand the database node to see all the available databases. While expanding the database node, there is a chance you might get the error like “Failure to coonect the server”, if you are getting this error, nothing to worry just right click on the Database node –> click on the Refresh option and then double click the database node or expand the Database node again.
In my case the available databases are master and TsinfoSQL. I want to rename the TsinfoSQL database to TsinfoSQLNew.

3. Now click on the New Query option.

4. Paste the below SQL query and click on the Run button and you can able to see on the left side the Database name is changed from TsInfoSQL to TsInfoSQLNew.
ALTER DATABASE TsInfoSQL MODIFY NAME = TsInfoSQLNew ;

To cross check, you can navigate to the Azure Portal and verify the Azure SQL database name is changed to TsInfoSQLNew.

This is how you can rename the Azure SQL database using the Azure Data Studio.
Approach-2: Using SQL Server
You can also use Microsoft SQL Server to quickly rename your Azure SQL Database using the below steps.
- Launch Microsoft SQL Server Management Studio on your machine.
- On the Connect to Server window, provide the below details
- Server type: Choose the server type as Database Engine.
- Server name: Provide the server name.
- Authentication: Choose SQL Server Authentication.
- Login: Provide the username that you have set while creating the Azure SQL database
- Password: Provide the password that you have set for the username while creating the Azure SQL database.
Finally, click on the Connect button.

3. Expand the Databases node–> Right click on the Database that you wish to rename –> Select the Rename option as highlighted below.

4. Enter the new name of the Azure SQL database and press the Enter key. Now you can able to see the database name has been changed from TsInfoSQLNew to TsInfoSQLOld.

To cross check, Let’s navigate to Azure Portal and go to the Azure SQL database, you can able to see the Azure SQL database name has been changed to TsInfoSQLOld successfully.

Approach-3: Rename Azure SQL database PowerShell
Another way to rename your Azure SQL database is by using PowerShell. Follow the below steps.
- Run PowerShell ISE with Administrator mode.
- Copy paste the below command and make sure to change the server name
Set-AzSqlDatabase -DatabaseName 'Old database name' -NewName 'New database name' -ServerName 'servername' -ResourceGroupName 'Your resource group name'
Example:
Set-AzSqlDatabase -DatabaseName 'TsInfoSQLOld' -NewName 'TsInfoSQLNewDB' -ServerName 'tsinfo' -ResourceGroupName 'DEMORG1'
Once, you will run the above script, you might get the below errors which I also came across. You can fix those errors by following the respective links.
- The ‘Set-AzSqlDatabase’ command was found in the module ‘Az.Sql’
- The Resource database under the resource group was not found
After fixing the errors I ran the above command again and this time I got the expected output as below.
ResourceGroupName : DEMORG1
ServerName : tsinfo
DatabaseName : TsInfoSQLNewDB
Location : eastus
DatabaseId : ceae9749-f92e-4684-a7df-06f9103839d9
Edition : GeneralPurpose
CollationName : SQL_Latin1_General_CP1_CI_AS
CatalogCollation :
MaxSizeBytes : 34359738368
Status : Online
CreationDate : 11/5/2022 6:26:00 AM
CurrentServiceObjectiveId : 00000000-0000-0000-0000-000000000000
CurrentServiceObjectiveName : GP_S_Gen5_1
RequestedServiceObjectiveName : GP_S_Gen5_1
RequestedServiceObjectiveId :
ElasticPoolName :
EarliestRestoreDate : 11/5/2022 6:36:33 AM
Tags : {}
ResourceId : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1
/resourceGroups/DEMORG1/providers/Microsoft.Sql/ser
vers/tsinfo/databases/TsInfoSQLNewDB
CreateMode :
ReadScale : Disabled
ZoneRedundant : False
Capacity : 1
Family : Gen5
SkuName : GP_S_Gen5
LicenseType :
AutoPauseDelayInMinutes : 60
MinimumCapacity : 0.5
ReadReplicaCount :
HighAvailabilityReplicaCount :
CurrentBackupStorageRedundancy : Local
RequestedBackupStorageRedundancy : Local
SecondaryType :
MaintenanceConfigurationId : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1
/providers/Microsoft.Maintenance/publicMaintenanceC
onfigurations/SQL_Default
EnableLedger : False
You can see it here

To cross-check check the Azure SQL database name is actually changed or not, just verified by navigating to Azure Portal and could able to see that the Azure SQL database name is changed from TsInfoSQLOld to TsInfoSQLNewDB.

You may also like following the below articles
- How to create an Azure SQL database
- How To Change User Id And Password For Azure SQL Server Database
- How To Connect To Azure SQL Database
- Cannot Open Server Requested By The Login Azure SQL
- How To Deploy SQL Database To Azure
- How To Upload SQL Database To Azure
- How to get Azure SQL database connection string
Wrapping Up
In this article, we discussed how to rename the Azure SQL database using Azure Data Studio and Microsoft SQL Server. Thanks for reading this article !!!