Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 2.85 KB

File metadata and controls

57 lines (42 loc) · 2.85 KB
title PowerShell: Move a Database Between Elastic Pools
description Use an Azure PowerShell example script to move a database in SQL Database between two elastic pools.
author arvindshmicrosoft
ms.author arvindsh
ms.reviewer wiassaf, mathoma
ms.date 06/10/2025
ms.service azure-sql-database
ms.subservice elastic-pools
ms.topic sample
ms.custom
sqldbrb=1
devx-track-azurepowershell
ms.devlang powershell

Use PowerShell to create elastic pools and move a database between them

[!INCLUDEappliesto-sqldb]

This PowerShell script example creates two elastic pools, moves a pooled database in SQL Database from one SQL elastic pool into another SQL elastic pool, and then moves the pooled database out of the SQL elastic pool to be a single database in Azure SQL Database.

[!INCLUDE quickstarts-free-trial-note] [!INCLUDE updated-for-az] [!INCLUDE cloud-shell-try-it.md]

If you choose to install and use PowerShell locally, this tutorial requires Az PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.

Sample script

[!code-powershell-interactivemain]

Clean up deployment

Use the following command to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

Script explanation

This script uses the following commands. Each command in the table links to command-specific documentation.

Command Notes
New-AzResourceGroup Creates a resource group in which all resources are stored.
New-AzSqlServer Creates a server that hosts databases and elastic pools.
New-AzSqlElasticPool Creates an elastic pool.
New-AzSqlDatabase Creates a database in a server.
Set-AzSqlDatabase Updates database properties or moves a database into, out of, or between elastic pools.
Remove-AzResourceGroup Deletes a resource group including all nested resources.

Related content