Copying your SQL Database

If you ever need to move a copy of a  SQL database in Azure across servers then here is a quick easy way.

Continue reading

Advertisements

Copying your SQL Database

If you have created a SQL Database in Azure (PaaS) and need to make a copy of it on the same server I will show you how via a quick method.

When connected to your master database execute the following: It creates SAP2 based on SAP.

CREATE DATABASE SAP2 AS COPY OF SAP
 

To track the progress you can use the following query.

SELECT * FROM sys.dm_database_copies
WHERE partner_database = 'SAP2'
 

as

Replication state 1 means seeding, this means that the SAP2 database has not yet completely synchronised with the original database. 0 means pending, which means that the copy is being prepared.

Once this has completed you can check sys.databases to confirm that the database has successful been created.

SELECT * FROM sys.databases
WHERE name = 'SAP2'
 

as1

If you really want you can query sys.dm_operation_status to see the operations that have been performed on a database. I would expect to see some sort of operation around copying on my original database.

SELECT * FROM sys.dm_operation_status   WHERE major_resource_id = 'SAP'
ORDER BY start_time DESC;
 

as3.JPG

If you are interested in other Azure based SQL queries check out an older post of mine: https://blobeater.wordpress.com/2016/10/18/azure-sql-database-dmvs/