This page describes how to migrate your data to an instance running a later
version of SQL Server. Before proceeding with this method, consider
[upgrading the database major version in-place](https://docs.cloud.google.com/sql/docs/sqlserver/upgrade-major-db-version-inplace.md.txt).

## Plan a major version upgrade

1. Choose a target major version and edition.

   See the [list of versions that Cloud SQL supports](https://docs.cloud.google.com/sql/docs/sqlserver/db-versions.md.txt).
2. Consider the features offered in each SQL Server version and address
   incompatibilities.

   New major versions introduce incompatible changes that might require you to
   modify the application code, the schema, or the database settings before
   you can upgrade your database instance. Review the release notes of your
   target major version to determine the incompatibilities that you need to
   address. If you're skipping major versions, address the incompatibilities
   listed for each version that you're skipping.
   - [SQL Server 2022](https://learn.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-2022?view=sql-server-ver16)
   - [SQL Server 2019](https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-ver15?view=sql-server-ver15)
   - [SQL Server 2017](https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-2017?view=sql-server-ver15)
3. Test the upgrade with a dry run.

   Perform a dry run of the end-to-end upgrade process with a test instance
   before you upgrade the production database. You might want to test the upgrade
   using a [clone](https://docs.cloud.google.com/sql/docs/sqlserver/clone-instance.md.txt)
   instead of your production database to avoid any performance impact from the
   export on your production workload.

   In addition to validating that the upgrade completes successfully, run
   tests to understand the expected downtime of the upgrade, confirm your
   upgrade workflow, and ensure that the application behaves as expected on the upgraded
   database. If you haven't enabled [automatic storage increases](https://docs.cloud.google.com/sql/docs/sqlserver/instance-settings.md.txt#automatic-storage-increase-2ndgen),
   take note of the disk storage used by the upgraded dry run instance to
   determine whether you need to increase the storage capacity for the
   production instance before upgrading.
4. Decide when you want to upgrade.

   > [!NOTE]
   > **Note:** Upgrades require the instance to become unavailable for a period of time. Be sure to schedule your upgrade when database activity is low.

## Migrate your data

Migrating entails [exporting the data](https://docs.cloud.google.com/sql/docs/sqlserver/import-export/import-export-bak.md.txt#export_data_to_a_bak_file)
from the source instance to a BAK file and [importing the data](https://docs.cloud.google.com/sql/docs/sqlserver/import-export/import-export-bak.md.txt#import_data_from_a_bak_file)
into the target instance.

To migrate your data to a Cloud SQL instance running a more recent database
version, follow these steps:

1. Create the target instance with the desired SQL Server version.

   Make sure the target instance has:
   - Sufficient storage to hold all of the current instance's data.
   - The same authorized networks as the current instance. [Learn more](https://docs.cloud.google.com/sql/docs/sqlserver/configure-ip.md.txt).
   - The same user accounts, with the same SQL Server privileges and passwords.

   For more information, see [Creating an instance](https://docs.cloud.google.com/sql/docs/sqlserver/create-instance.md.txt).
2. Confirm that you can [connect to the new instance](https://docs.cloud.google.com/sql/docs/sqlserver/connect-admin-ip.md.txt)
   with your local SQL Server tools and update them, if necessary.

3. Export the current instance's data to a SQL Server BAK file by following the
   instructions in
   [Export data to a BAK file](https://docs.cloud.google.com/sql/docs/sqlserver/import-export/import-export-bak.md.txt#export_data_to_a_bak_file).

   Do *not* export the `sqlserver` system database. The `sqlserver` database is
   the default database you connect to before you create any other
   databases. After you create another database, switch to the new database
   to create tables and insert data. Don't use the `sqlserver` database for your
   application's data.
4. [Create a Cloud Storage bucket](https://docs.cloud.google.com/storage/docs/creating-buckets.md.txt)
   if needed, and upload your BAK file to the bucket.

5. Import the data to the target instance by following the instructions in
   [Import from a BAK file](https://docs.cloud.google.com/sql/docs/sqlserver/import-export/import-export-bak.md.txt#import_data_from_a_bak_file).

6. Update your applications to connect to the new instance.

7. Upgrade the [database compatibility level](https://docs.cloud.google.com/sql/docs/sqlserver/upgrade-major-db-version-inplace.md.txt#db-compat).

8. When you're confident that your new instance is operating successfully,
   delete the old instance.

## What's next

- Learn about [importing and exporting data](https://docs.cloud.google.com/sql/docs/sqlserver/import-export.md.txt).
- Learn about [options for connecting to an instance](https://docs.cloud.google.com/sql/docs/sqlserver/external-connection-methods).