CREATE DATABASE, AS COPY OF in Azure SQL Database

Recently I had a conversion about the options available to create a copy of a production database for testing and development. There are, the enhanced, CREATE DATABASE and the standard Restore database options available.

We’ve got the restore database option, using the portal, which provides an extremely simple way to restore a database to a point in time depending on what tier you are on, naming the database automatically with a timestamp (i.e. databasename_2016-08-17T08-20Z ).

In Azure SQL Database we also have a CREATE DATABASE T-SQL command with a more advanced feature that enbales you to make a copy of a database, also choosing its tier/service objective and, if required, server.

CREATE DATABASE database_copy 
AS COPY OF database
(SERVICE_OBJECTIVE = 'BASIC')

The largest caveat here is that to run this T-SQL command the user, essentially, needs administrator rights on the server. However in a test environment it makes it easy to make a complete copy of your test database quickly.

Thanks for Reading!

CREATE DATABASE, AS COPY OF in Azure SQL Database

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest