5

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

1
  • 1
    For AzureRM command, the -NewName parameter doesn't exists anymore. But not sure if the rename is feasible as per new feature. Commented Apr 16, 2018 at 7:43

2 Answers 2

10

using Az.Sql module the command command would be:

Set-AzSqlDatabase -DatabaseName <sourceDbName> -NewName <targetDbName> -ServerName <server1> -ResourceGroupName <resgroup1>
Sign up to request clarification or add additional context in comments.

Comments

8

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

2 Comments

If you want to use an AzureRM command, use the following syntax: Set-AzureRMSqlDatabase -ResourceGroupName $ResourceGroupName -ServerName $SQLServerName -DatabaseName $DatabaseName -NewName $NewDatabaseName
Command is outdated. It is now: Set-AzSqlDatabase. Also NewDatabaseName is now -NewName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.