How is the database location decided when creating a copy using SQL Management client API?

73 Views Asked by At

This is the code to create a database copy in Azure using service management api's

SqlManagementClient sqlClient = new SqlManagementClient sqlClient ();
DatabaseCopyCreateParameters newDatabaseParameters = new DatabaseCopyCreateParameters()
                    {
                        IsContinuous = true,
                        PartnerDatabase = srcDB
                        PartnerServer = srcserver
                    };
sqlClient.DatabaseCopies.Create(dbservername, dbname, newDatabaseParameters);

It got created in the location say "east asia".

As you can see I am not providing any location details, then how it is created in this location?

2

There are 2 best solutions below

0
On

You can avoid this by copying the database using T-SQL as explained below:

-- Execute on the master database of the target server (server2)
-- Start copying from Server1 to Server2
CREATE DATABASE Database1_copy AS COPY OF server1.Database1;

For more information, click here.

Hope this helps.

0
On

Location is decided based on the server location. Since my server is in East Asia, Obviously db will be in East Asia