Tuesday, August 11, 2020

Create Azure SQL Staging | Testing Database

 Create Azure SQL Staging | Testing Database

We can do that by copying the current production database on either the same server or a different server using one of the following ways :

1- Using Azure Portal :

Azure SQL >> From the top bar click Copy >> then follow the wizard 


2- Using Transact-SQL:

- Log into the Master database and excute this script:

CREATE DATABASE [StagingDatabaseName] AS COPY OF MyServerName.[SourceDatabaseName]

- To monitor the Progress:

          SELECT * FROM sys.dm_database_copies


3- Using Azure CLI :

az sql db copy --dest-name "CopyOfMySampleDatabase" --dest-resource-group "myResourceGroup" --dest-server $targetserver `

    --name "<databaseName>" --resource-group "<resourceGroup>" --server $sourceserver


4- Using PowerShell:

New-AzSqlDatabaseCopy -ResourceGroupName "<resourceGroup>" -ServerName $sourceserver -DatabaseName "<databaseName>" `

    -CopyResourceGroupName "myResourceGroup" -CopyServerName $targetserver -CopyDatabaseName "CopyOfMySampleDatabase"

No comments: