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 functionality, you should know the prerequisites to perform this operation.
Prerequisites
- You must Download and install Azure Data Studio.
- You must have an Azure Account or Azure Subscription. You can create an Azure Free account now If you don’t have one.
- Install the updated version of Microsoft SQL Server Management Studio.
Let’s start with the actual functionality if you are ready with all the prerequisites.
You can rename the Azure SQL database using Azure Data Studio, 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 the 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 an error like “Failure to connect the server.” If you are getting this error, there is nothing to worry about; 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. On the left side, the Database name is changed from TsInfoSQL to TsInfoSQLNew.
ALTER DATABASE TsInfoSQL MODIFY NAME = TsInfoSQLNew ;
To cross-check, navigate to the Azure Portal and verify the Azure SQL database name has been 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 rename your Azure SQL Database using the steps below quickly.
- 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 you 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 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 see the database name has been changed from TsInfoSQLNew to TsInfoSQLOld.

To cross-check, navigate to Azure Portal and the Azure SQL database. 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 and paste the below command, and 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 run the above script, you might get the below errors, which I also encountered. You can fix those errors by following the respective links.
After fixing the errors, I reran the above command, 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 : FalseYou can see it here.

To cross-check whether the Azure SQL database name is changed, verify by navigating to Azure Portal and seeing that the Azure SQL database name is changed from TsInfoSQLOld to TsInfoSQLNewDB.

You may also like following the articles below
- 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 get Azure SQL database connection string
Wrapping Up
This article discussed how to rename the Azure SQL database using Azure Data Studio and Microsoft SQL Server. Thanks for reading this article !!!

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
