Dimuth Lochana
Dimuth Lochana

Reputation: 249

Rename azure sql database using powershell

I've created azure database using powershell. Now i want to rename the database using powershell. My purpose to do this is creating temporary database, then deploy database release to temp DB,then rename production db to any other name, finaly rename Temp Db to production db

Upvotes: 5

Views: 5785

Answers (2)

Dariusz Szczepaniak
Dariusz Szczepaniak

Reputation: 196

using Az.Sql module the command command would be:

Set-AzSqlDatabase -DatabaseName <sourceDbName> -NewName <targetDbName> -ServerName <server1> -ResourceGroupName <resgroup1>

Upvotes: 10

Thibaut Ranise
Thibaut Ranise

Reputation: 715

To achieve this, you can use the cmdlet "Set-AzureSqlDatabase", the parameter "-NewDatabaseName" permits to set a new name for a specified database name.

Set-AzureSqlDatabase -ServerName 'myservername' -DatabaseName 'mydb' -NewDatabaseName 'newNameForTheDb' 

Here is the documentation : https://msdn.microsoft.com/fr-fr/library/dn546732.aspx

Upvotes: 8

Related Questions