Azure overwrite existing database copy

Robert Sheppard 1 Reputation point
2022-02-02T19:54:45.627+00:00

I have a production database and a copy of the production database that I use for testing. So Im paying for 2 databases in my prescription. I would like to update the copy once in awhile with updated production data. Is there a way to do this? Do I have to delete the copy and re-create it? If so how does that affect my subscription? I would have to go through the copy process again... I dont want it do create a third database. Is there a better way to manage this scenario. Again I want a copy of my production database that I an use for testing and I want it to be updated with production data on a schedule or manually.

Azure SQL Database
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Patrick C 81 Reputation points
    2022-02-02T20:47:31.727+00:00

    Hi,
    It would be useful to have a bit more details. For instance, are you using it only to test? What are you using in order to develop?

    You could use something like this from a TEST server:

    DROP DATABASE IF EXISTS [YOURDBNAME]
    CREATE DATABASE [YOURDBNAME] AS COPY OF [YOURPRODUCTIONSERVER].YOURDBNAME;

    See https://learn.microsoft.com/en-us/azure/azure-sql/database/database-copy for more info

    Depending on how your users/logins are configured ( contained users vs logins) you will need to fix them each time.

    Hope it helps!
    Patrick


  2. Alberto Morillo 32,891 Reputation points MVP
    2022-02-02T21:06:52.44+00:00

    Robert,

    To my understanding you want to avoid the process of dropping the test database and recreate it again via a copy operation. You also want to manually update the test database with data coming from Production, or update it once a month.

    Please consider using SQL Data Sync tp sync your Production database with the test database either manually or automatically (with a monthly frequency). You can get started with SQL Data Sync here. You can sync both Azure SQL databases.

    Hope this helps.