title: PowerShell example-move Azure SQL database-SQL elastic pool | Microsoft Docs description: Azure PowerShell example script to move a SQL database between elastic pools using PowerShell services: sql-database ms.service: sql-database ms.subservice: data-movement ms.custom: ms.devlang: PowerShell ms.topic: sample author: CarlRabeler ms.reviewer: ms.author: carlrab manager: craigg ms.date: 09/14/2018
This PowerShell script example creates two elastic pools and moves a database from one elastic pool into another elastic pool, and then moves a database out of an elastic pool to a single database compute size.
[!INCLUDE quickstarts-free-trial-note] [!INCLUDE cloud-shell-powershell.md]
If you choose to install and use the PowerShell locally, this tutorial requires the Azure PowerShell module version 5.7.0 or later. Run Get-Module -ListAvailable AzureRM
to find the version. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzureRmAccount
to create a connection with Azure.
[!code-powershell-interactivemain]
After the script sample has been run, the following command can be used to remove the resource group and all resources associated with it.
Remove-AzureRmResourceGroup -ResourceGroupName $resourcegroupname
This script uses the following commands. Each command in the table links to command specific documentation.
Command | Notes |
---|---|
New-AzureRmResourceGroup | Creates a resource group in which all resources are stored. |
New-AzureRmSqlServer | Creates a logical server that hosts a database or elastic pool. |
New-AzureRmSqlElasticPool | Creates an elastic pool within a logical server. |
New-AzureRmSqlDatabase | Creates a database in a logical server as a single or a pooled database. |
Set-AzureRmSqlDatabase | Updates database properties or moves a database into, out of, or between elastic pools. |
Remove-AzureRmResourceGroup | Deletes a resource group including all nested resources. |
For more information on the Azure PowerShell, see Azure PowerShell documentation.
Additional SQL Database PowerShell script samples can be found in the Azure SQL Database PowerShell scripts.