This page describes how to migrate your Cloud SQL for SQL Server databases to another
Cloud SQL for SQL Server instance with Database Migration Service. With this migration flow,
you can move your databases to another Cloud SQL for SQL Server instance in the same
or a different Google Cloud project, and upgrade your databases to a later
Cloud SQL for SQL Server major version (for example, migrating from SQL Server 2017
to SQL Server 2019, 2022, or 2025) with minimal downtime.
For instructions on how to migrate from self-managed or Amazon RDS sources,
see [Migration guide for self-hosted and Amazon RDS sources](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/guide.md.txt).

The migration process for Cloud SQL for SQL Server sources involves the following tasks:

1. Configuring your source Cloud SQL for SQL Server instance so that Database Migration Service
   can automatically export backup files to a Cloud Storage bucket.

2. Creating a source connection profile with Google Cloud CLI.

3. Creating the destination Cloud SQL for SQL Server instance.

4. Creating and running the migration job in Database Migration Service with Google Cloud CLI.

5. Monitoring the migration job progress with Database Migration Service observability
   features.

6. Promoting the migration job after the data is fully migrated.

## Costs

For homogenous migrations to Cloud SQL, Database Migration Service is offered
at no additional charge. However, Cloud SQL and Cloud Storage pricing
applies for network charges as well as Cloud SQL and Cloud Storage
entities created for migration purposes.

In this document, you use the following billable components of
Google Cloud:

- Cloud Storage
- Cloud SQL

To generate a cost estimate based on your projected usage, use the
[pricing calculator](https://docs-0cloud-0google-0com.linkedin.net.nz/products/calculator).

## Before you begin

1. Verify if this migration path can fully support your scenario. See [SQL Server
   Known limitations](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/known-limitations).
2. Consider in which region you want to create the destination database. Database Migration Service is a fully-regional product, meaning all entities related to your migration (source and destination connection profiles, migration jobs, destination databases, storage buckets) must be saved in a single region.
3. In the Google Cloud console, on the project selector page, select or [create a Google Cloud project](https://docs-0cloud-0google-0com.linkedin.net.nz/resource-manager/docs/creating-managing-projects.md.txt).

   [Go to project selector](https://console-0cloud-0google-0com.linkedin.net.nz/projectselector2/home/dashboard)
4. Enable the Database Migration Service, Compute Engine, Cloud Storage, and Cloud SQL Admin APIs. [Enable the APIs](https://console-0cloud-0google-0com.linkedin.net.nz/flows/enableapi?apiid=compute.googleapis.com,datamigration.googleapis.com,sqladmin.googleapis.com,storage.googleapis.com)

### Required roles

To get the permissions that you need to perform homogeneous migrations between
two Cloud SQL for SQL Server instances with Database Migration Service, ask your administrator to grant the
required IAM roles to the
[accounts involved in the migration process](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/access-control.md.txt) in the relevant projects.

This scenario lets you migrate between two Cloud SQL for SQL Server instances that
reside in different Google Cloud projects. If you want to migrate between
instances in the same project, grant all the permissions in the same project.
For more information about granting roles, see
[Manage access](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/granting-changing-revoking-access.md.txt).

#### Roles and permissions in the source project

Grant the following roles to specific accounts on the Google Cloud project
where your **source** Cloud SQL for SQL Server instance resides:

- User account that performs the migration:
  - [Storage Admin](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/storage.md.txt#storage.admin) (`roles/storage.admin`)
  - [Cloud SQL Editor](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.editor) (`roles/cloudsql.editor`)
- Database Migration Service service account of the **destination** instance project:
  - [Cloud SQL Viewer](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.viewer) (`roles/cloudsql.viewer`)
  - [Cloud SQL Studio User](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.studioUser) (`roles/cloudsql.studioUser`)

These predefined roles contain the permissions required to perform homogeneous
SQL Server migrations with Database Migration Service. To see the exact permissions
that are required, expand the **Required permissions (source project)** section:

#### Required permissions (source project)

The following permissions are required to perform homogeneous SQL Server
migrations with Database Migration Service:

- User account that performs the migration:
  - `resourcemanager.projects.get`
  - `resourcemanager.projects.list`
  - `cloudsql.operations.get`
  - `cloudsql.instances.create`
  - `cloudsql.instances.get`
  - `cloudsql.instances.list`
  - `cloudsql.instances.import`
  - `cloudsql.databases.get`
  - `cloudsql.databases.list`
  - `cloudsql.databases.delete`
  - `compute.machineTypes.list`
  - `compute.machineTypes.get`
  - `compute.projects.get`
  - `storage.buckets.create`
  - `storage.buckets.list`
- **Destination project** Database Migration Service service account:
  - `cloudsql.instances.export`
  - `cloudsql.instances.get`
  - `cloudsql.instances.list`
  - `cloudsql.instances.executeSql`

You might also be able to get these permissions with
[custom roles](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/creating-custom-roles.md.txt) or other
[predefined roles](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions.md.txt).

#### Roles and permissions in the destination project

Grant the following roles to specific accounts on the Google Cloud project
where your **destination** Cloud SQL for SQL Server instance resides:

- User account that performs the migration:
  - [Database Migration Admin](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/datamigration.md.txt#datamigration.admin) (`roles/datamigration.admin`)
  - [Storage Admin](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/storage.md.txt#storage.admin) (`roles/storage.admin`)
  - [Cloud SQL Editor](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.editor) (`roles/cloudsql.editor`)
- Database Migration Service service account of the destination instance project:
  - [Database Migration Admin](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/datamigration.md.txt#datamigration.admin) (`roles/datamigration.admin`)
  - [Cloud SQL Editor](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.editor) (`roles/cloudsql.editor`)
  - [Cloud SQL Studio User](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/cloudsql.md.txt#cloudsql.studioUser) (`roles/cloudsql.studioUser`)
- Cloud SQL service account associated with the **source** instance: [Storage Object User](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/storage.md.txt#storage.objectUser) (`roles/storage.objectUser`)

  This permission is required to let your source Cloud SQL for SQL Server instance
  to save exported backup files to the Cloud Storage bucket you
  create in the **destination project**.

These predefined roles contain the permissions required to perform homogeneous
SQL Server migrations with Database Migration Service. To see the exact permissions
that are required, expand the **Required permissions (destination project)** section:

#### Required permissions (destination project)

The following permissions are required to perform homogeneous SQL Server
migrations with Database Migration Service:

- User account that performs the migration:
  - `datamigration.* `
  - `resourcemanager.projects.get`
  - `resourcemanager.projects.list`
  - `cloudsql.operations.get`
  - `cloudsql.instances.create`
  - `cloudsql.instances.get`
  - `cloudsql.instances.list`
  - `cloudsql.instances.import`
  - `cloudsql.databases.get`
  - `cloudsql.databases.list`
  - `cloudsql.databases.delete`
  - `compute.machineTypes.list`
  - `compute.machineTypes.get`
  - `compute.projects.get`
  - `storage.buckets.create`
  - `storage.buckets.list`
- Database Migration Service service account:
  - `datamigration.* `
  - `resourcemanager.projects.get`
  - `resourcemanager.projects.list`
  - `cloudsql.instances.create`
  - `cloudsql.instances.get`
  - `cloudsql.instances.list`
  - `cloudsql.instances.executeSql`
  - `storage.objects.create`
  - `storage.objects.list`
- Cloud SQL service account associated with the **source** instance:
  - `storage.objects.create`
  - `storage.objects.list`
  - `storage.objects.get`

You might also be able to get these permissions with
[custom roles](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/creating-custom-roles.md.txt) or other
[predefined roles](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions.md.txt).

## Prepare your source Cloud SQL instance

1. [Create a Cloud Storage bucket](https://docs-0cloud-0google-0com.linkedin.net.nz/storage/docs/creating-buckets.md.txt) in the **destination**
   Google Cloud project. This bucket is used to store backup log files exported
   from your source Cloud SQL for SQL Server instance.

   - We recommend that you configure data retention period to be between `14` and `30` days for these backup files.
   - The Cloud SQL service account associated with your **source** instance needs the [Storage Object User](https://docs-0cloud-0google-0com.linkedin.net.nz/iam/docs/roles-permissions/storage.md.txt#storage.objectUser) (`roles/storage.objectUser`) IAM role to write the backup files to this bucket. For more information on permissions for this migration flow, see the [Required roles](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/csql-sql-server-src-guide.md.txt#required-roles) section.
2. [Configure your source Cloud SQL for SQL Server instance](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/configure-source-database-csql.md.txt).

3. [Create a source connection profile](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/create-source-connection-profile.md.txt) for the Cloud SQL for SQL Server source instance.

## Prepare your Cloud SQL for SQL Server destination instance

To configure your destination Cloud SQL instance, perform the following steps:

1. [Create and configure your Cloud SQL for SQL Server destination instance](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/create-cloud-sql-destination-instance.md.txt).
   Make sure you use enough compute and memory resources to cover your migration needs.

2. [Create a destination connection profile](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/create-destination-connection-profile.md.txt) for your Cloud SQL instance.

## Create and run the migration job

1. [Create and run the migration job for a Cloud SQL for SQL Server source](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/create-migration-job-csql-sql-server-sources.md.txt).

When you start the migration job, your destination Cloud SQL for SQL Server
databases are put into recovery mode where they are fully managed by
Database Migration Service. You can promote your destination instance
when your data is fully migrated. After your destination instance is promoted,
all the databases in that instance become fully operational. You also gain
full write access to those databases.

## Finalize the migration

When you decide to switch your application to the new Cloud SQL for SQL Server
instance, finalize the migration by following these steps:

1. Stop all write operations on your source databases. You can switch them to read-only mode to retain operational functionality.
2. [Promote the migration job](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/finalize-migration.md.txt).
3. (Optional) [Verify migration data](https://docs-0cloud-0google-0com.linkedin.net.nz/database-migration/docs/sqlserver/verify-migration.md.txt) for completeness.