Migrating data between SQL Server 2008 and Cloud SQL for SQL Server using backup files
Stay organized with collections
Save and categorize content based on your preferences.
In this tutorial, you migrate data from SQL Server 2008 to Cloud SQL
for SQL Server 2017 Enterprise. The tutorial shows you how to export the data
from SQL Server 2008, import the data to Cloud SQL for SQL Server 2017,
and validate that the data was successfully imported.
This tutorial is useful if you are a sysadmin, developer, engineer, database
admin, or DevOps engineer who wants to migrate data from SQL Server 2008 to
Cloud SQL for SQL Server 2017 or who wants to upgrade from SQL Server
2008 to SQL Server 2017.
The tutorial assumes that you have a license for SQL Server 2008 and that you're
familiar with the following:
To generate a cost estimate based on your projected usage,
use the pricing calculator.
New Google Cloud users might be eligible for a free trial.
When you finish the tasks that are described in this document, you can avoid
continued billing by deleting the resources that you created. For more information, see
Clean up.
Before you begin
In the Google Cloud console, on the project selector page, select or
create a Google Cloud project.
At the bottom of the Google Cloud console, a
Cloud Shell
session opens and displays a command-line prompt. Cloud Shell is a shell
environment with the Google Cloud CLI already installed, and with
values already set for your current project. It can take a few seconds for
the session to initialize.
Creating the Cloud SQL instance and Cloud Storage bucket
In Cloud Shell, create the Cloud SQL for SQL Server
2017 Enterprise instance that you later migrate the database to:
It can take a few minutes to create the instance. The default root username
is sqlserver with a default password of sqlserver12@. For this tutorial,
you create the instance in the us-central1-f zone. For more information
about zones, see
Cloud locations.
Create a Cloud Storage bucket to store the backup file before
the data is imported into Cloud SQL:
Replace bucket-name with a unique name for the
Cloud Storage bucket.
Backing up your database
In this section, you connect to your Windows server running SQL Server 2008,
create a backup of your database, and upload the backup database to
Cloud Storage.
Connect to your Windows server running SQL Server 2008 by using RDP. It
can be the primary or a replica server.
Google Cloud creates a service account when you created the
Cloud SQL instance. You use the service account to give the
Cloud SQL instance permission to access the resources it needs.
Give the service account permission to write to the
Cloud Storage bucket:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Migrating data between SQL Server 2008 and Cloud SQL for SQL Server using backup files\n\n*** ** * ** ***\n\nIn this tutorial, you migrate data from SQL Server 2008 to Cloud SQL for SQL Server 2017 Enterprise. The tutorial shows you how to export the data from SQL Server 2008, import the data to Cloud SQL for SQL Server 2017, and validate that the data was successfully imported.\n\n\u003cbr /\u003e\n\nIf you want to migrate data from SQL Server 2017, see\n[Migrating data between SQL Server 2017 and Cloud SQL for SQL Server using backup files](/solutions/migrating-data-between-sql-server-2017-and-cloud-sql-for-sql-server-using-backup-files).\n\nThis tutorial is useful if you are a sysadmin, developer, engineer, database\nadmin, or DevOps engineer who wants to migrate data from SQL Server 2008 to\nCloud SQL for SQL Server 2017 or who wants to upgrade from SQL Server\n2008 to SQL Server 2017.\n\nThe tutorial assumes that you have a license for SQL Server 2008 and that you're\nfamiliar with the following:\n\n- Microsoft SQL Server 2008\n- Microsoft SQL Server 2017\n- Microsoft PowerShell\n- [Cloud Storage](/storage)\n- [Cloud SQL](/sql/docs/sqlserver)\n\nObjectives\n----------\n\n- Create a Cloud SQL for SQL Server instance.\n- Create a Cloud Storage bucket.\n- Back up your database.\n- Import the database into Cloud SQL for SQL Server.\n- Validate the imported data.\n\nCosts\n-----\n\n\nIn this document, you use the following billable components of Google Cloud:\n\n\n- [Cloud SQL](/sql/pricing)\n- [Cloud Storage](/storage/pricing)\n\n\nTo generate a cost estimate based on your projected usage,\nuse the [pricing calculator](/products/calculator). \nNew Google Cloud users might be eligible for a [free trial](/free). \n\n\u003cbr /\u003e\n\nWhen you finish the tasks that are described in this document, you can avoid\ncontinued billing by deleting the resources that you created. For more information, see\n[Clean up](#clean-up).\n\nBefore you begin\n----------------\n\n1. In the Google Cloud console, on the project selector page, select or\n create a Google Cloud project.\n\n | **Note:** If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [GO TO THE PROJECT SELECTOR PAGE](https://console.cloud.google.com/projectselector2/home/dashboard)\n2. Make sure that billing is enabled for your Google Cloud project.\n [Learn how to confirm billing is enabled for your project](/billing/docs/how-to/modify-project).\n\n3. Enable the Cloud Storage and Cloud SQL APIs.\n\n [ENABLE THE APIS](https://console.cloud.google.com/flows/enableapi?apiid=sqladmin,storage_component)\n4. [Install and initialize the Google Cloud CLI](/sdk/docs/install)\n on the server that's running SQL Server 2008.\n\n5. In the Google Cloud console, go to Cloud Shell.\n\n [GO TO Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\n At the bottom of the Google Cloud console, a\n [Cloud Shell](/shell/docs/features)\n session opens and displays a command-line prompt. Cloud Shell is a shell\n environment with the Google Cloud CLI already installed, and with\n values already set for your current project. It can take a few seconds for\nthe session to initialize. \n\nCreating the Cloud SQL instance and Cloud Storage bucket\n--------------------------------------------------------\n\n1. In Cloud Shell, create the Cloud SQL for SQL Server\n 2017 Enterprise instance that you later migrate the database to:\n\n gcloud beta sql instances create target \\\n --database-version=SQLSERVER_2017_ENTERPRISE \\\n --cpu=2 \\\n --memory=5GB \\\n --root-password=sqlserver12@ \\\n --zone=us-central1-f\n\n It can take a few minutes to create the instance. The default root username\n is `sqlserver` with a default password of `sqlserver12@`. For this tutorial,\n you create the instance in the `us-central1-f` zone. For more information\n about zones, see\n [Cloud locations](/about/locations).\n2. Create a Cloud Storage bucket to store the backup file before\n the data is imported into Cloud SQL:\n\n ```\n gcloud storage buckets create \"gs://bucket-name\" --location=US\n ```\n\n Replace \u003cvar translate=\"no\"\u003ebucket-name\u003c/var\u003e with a unique name for the\n Cloud Storage bucket.\n\nBacking up your database\n------------------------\n\nIn this section, you connect to your Windows server running SQL Server 2008,\ncreate a backup of your database, and upload the backup database to\nCloud Storage.\n\n1. Connect to your Windows server running SQL Server 2008 by using RDP. It\n can be the primary or a replica server.\n\n2. Launch the PowerShell command-line tool.\n\n3. In the terminal where you\n [installed the gcloud CLI](/sdk/docs),\n create a backup folder:\n\n mkdir c:\\backup\n\n4. Create a backup of the database in the backup folder:\n\n ```\n osql -E -Q \"BACKUP DATABASE db-name TO DISK='c:\\backup\\db-name.bak'\"\n ```\n\n Replace \u003cvar translate=\"no\"\u003edb-name\u003c/var\u003e with the name of the database that\n you want to migrate to Cloud SQL.\n5. Copy the backup file to the Cloud Storage bucket:\n\n ```\n $PROJECT_ID = (gcloud sql instances describe target --format='value(project)' )\n gcloud storage cp c:\\backup\\db-name.bak gs://bucket-name --no-clobber\n ```\n\nImporting the backup file to Cloud SQL\n--------------------------------------\n\n1. In Cloud Shell, retrieve the service account that's associated with\n the Cloud SQL instance and save it in a variable:\n\n SVC_EMAIL_ADDRESS=$(gcloud sql instances describe target \\\n --format='value(serviceAccountEmailAddress)')\n echo $SVC_EMAIL_ADDRESS\n\n Google Cloud creates a service account when you created the\n Cloud SQL instance. You use the service account to give the\n Cloud SQL instance permission to access the resources it needs.\n2. Give the service account permission to write to the\n Cloud Storage bucket:\n\n ```\n gcloud storage buckets add-iam-policy-binding gs://bucket-name \\\n --member=serviceAccount:${SVC_EMAIL_ADDRESS} \\\n --role=roles/storage.legacyBucketWriter\n ```\n3. Give the service account permission to read files in the\n Cloud Storage bucket:\n\n ```\n gcloud storage buckets add-iam-policy-binding gs://bucket-name \\\n --member=serviceAccount:${SVC_EMAIL_ADDRESS} \\\n --role=roles/storage.legacyObjectReader\n ```\n4. Import the backup file to the Cloud SQL database:\n\n ```\n gcloud beta sql import bak target \\\n gs://bucket-namedb-name.bak \\\n --database db-name\n ```\n\nValidating the data import\n--------------------------\n\nIn this section, you check that the data was successfully imported.\n\n1. In Cloud Shell, install the\n [SQL Server toolkit](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15):\n\n sudo apt-get install -y mssql-tools\n\n If you accept the license terms, enter `yes` when you're prompted.\n2. To securely access your Cloud SQL instance, download the\n [Cloud SQL proxy](https://cloud.google.com/sql/docs/mysql/sql-proxy):\n\n wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy\n\n3. Start the Cloud SQL proxy:\n\n CONNECTION_NAME=$(gcloud sql instances describe target --format='value(connectionName)')\n ./cloud_sql_proxy -instances=${CONNECTION_NAME}=tcp:1433 &\n\n4. Run a query to validate the data in one or more of the tables:\n\n ```\n /opt/mssql-tools/bin/sqlcmd -U sqlserver -S 127.0.0.1 -Q \"query-string\"\n ```\n\n Replace \u003cvar translate=\"no\"\u003equery-string\u003c/var\u003e with the SQL query that you\n want to run.\n\n When you're prompted, enter the `sqlserver12@` password.\n\nClean up\n--------\n\nThe easiest way to eliminate billing is to delete the Google Cloud project you created for the tutorial.\n\n\u003cbr /\u003e\n\n### Delete the project\n\n| **Caution** : Deleting a project has the following effects:\n|\n| - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.\n| - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.\n1. In the Google Cloud console, go to the **Manage resources** page.\n\n [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)\n2. In the project list, select the project that you want to delete, and then click **Delete**.\n3. In the dialog, type the project ID, and then click **Shut down** to delete the project.\n\nWhat's next\n-----------\n\n- Read about [customer-managed encryption keys (CMEK) for Cloud SQL for SQL Server](/sql/docs/sqlserver/configure-cmek).\n- Read about [configuring private IP connectivity for Cloud SQL for SQL Server](/sql/docs/sqlserver/configure-private-ip).\n- Explore reference architectures, diagrams, and best practices about Google Cloud. Take a look at our [Cloud Architecture Center](/architecture)."]]