Connect to Cloud SQL for SQL Server from SSMS
This page shows you how to create and connect to a SQL Serverinstance and perform basic SQL operations by using the Google Cloud console anda client. The resources created in this quickstart typically cost less than adollar, assuming you complete the steps, including the cleanup, in a timelymanner.
Before you begin
Note:The name you use for your project must be between 4 and 30 characters. When youtype the name, the form suggests a project ID, which you can edit. Theproject ID must be between 6 and 30 characters, with a lowercase letteras the first character. You can use a dash, lowercase letter, or digit for theremaining characters, but the last character cannot be a dash.- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
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.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
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.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify that billing is enabled for your Google Cloud project.
- Enable the necessary Google Cloud APIs.
Console
In the Google Cloud console, go to theAPIs page.
Enable the Cloud SQL Admin API.gcloud
Click the following button to open Cloud Shell, which provides command-line access to your Google Cloud resources directly from the browser. Cloud Shell can be used to run the
gcloudcommands presented throughout this quickstart.Run the
gcloud services enablecommand as follows using Cloud Shell to enable the APIs required for this quickstart.:gcloudservicesenablesqladmin.googleapis.comThis command enables the following APIs:
- Cloud SQL Admin API
Make sure that you have the following role or roles on the project: Cloud SQL Admin (
roles/cloudsql.admin)Check for the roles
In the Google Cloud console, go to theIAM page.
Go to IAM- Select the project.
In thePrincipal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check theRole column to see whether the list of roles includes the required roles.
Grant the roles
In the Google Cloud console, go to theIAM page.
Go to IAM- Select the project.
- ClickGrant access.
In theNew principals field, enter your user identifier. This is typically the email address for a Google Account.
- In theSelect a role list, select a role.
- To grant additional roles, clickAdd another role and add each additional role.
- ClickSave.
Create a Cloud SQL instance
In this quickstart, you use the Google Cloud console. To use thegcloud CLI, cURL, or PowerShell, seeCreate instances.
In the Google Cloud console, go to theCloud SQL Instances page.
- ClickCreate instance.
- ClickChoose SQL Server.
- In theInstance ID field, enter
myinstance. - In thePassword field, enter a password for the
sqlserveruser. ClickCreate instance.
You're returned to the instances list. You can click the new instance rightaway to see the details, but it won't be available for other operations until it initializes and starts.
Note: In this example, the instance is created using default settings, including a public IP address.
Connect to your instance by using SQL Server Management Studio
Note: SQL Server Management Studio (SSMS) is aWindows-based, integrated environment. Review theSSMS documentation if needed, including forConnecting to a SQL Server instance. Alternatively, you can use otherdatabase administration tools.- Optional: If you're running a local instance of SQL Server, stop it beforeconnecting to your Cloud SQL instance. Otherwise, you might encountererrors such as
address already in use. - Install thegcloud CLI. Thegcloud CLI provides the gcloud CLI to interact with Cloud SQL and other Google Cloud services. The gcloud CLI uses the Admin API to access Cloud SQL, so you must Enable the Admin API before using the gcloud CLI to access Cloud SQL.
- In a bash shell command prompt or in Windows PowerShell, run the following command to initialize the gcloud CLI:
gcloudinit
- Run the following command to authenticate the gcloud CLI:
gcloudauthlogin
- Download and install the Cloud SQL Auth Proxy (see Installing the Cloud SQL Auth Proxy). Note the location of the Cloud SQL Auth Proxy because you will run the Cloud SQL Auth Proxy in next step.
- Run the Cloud SQL Auth Proxy by using a bash shell command prompt (or by using Windows PowerShell). Specifically, run the following command, replacing
Instance-connection-namewith the corresponding value from the Google Cloud console's Overview tab (for your instance):./cloud-sql-proxyINSTANCE_CONNECTION_NAME
For more information about installing and using the Cloud SQL Auth Proxy, seeAbout the Cloud SQL Auth Proxy.
As described in the next section, now you can connect to your SQL Serverinstance by using SSMS and the localhost IP address.
Connect using the SSMS Object Explorer
In SSMS, selectConnect Object Explorer from theFile menu.

Enter the following values in theConnection dialog:
- For Server Type, enterDatabase Engine.
- For Server Name, enter 127.0.0.1 as the IP address of your SQL Server instance.
- For Authentication, enterSQL Server Authentication.
- For Login, entersqlserver.
- For Password, enter the password used when the instance was created.
- Click theConnect button.
Create a database and upload data
In the SSMS Object Explorer window, right-click theDatabases node underyour instance and selectNew Database.

Entertestdb for theDatabase name and click theOK button.

Under the newly createdtestdb database, right-click theTables node andselectNew > Table.

Enter the following values in theCreate table dialog:
- In theProperties window, forIdentity > Name, enterguestbook.
- For the firstColumn Name, enterentryID, set its Data Type toint, and clear theAllow Nulls checkbox.
- In theColumn Properties window, expand theIdentitySpecification item and set(Is Identity) toYes.
- For the secondColumn Name, enterguestname and set itsData Type to varchar(255).
- For the thirdColumn Name, entercontent and set its Data Typeto varchar(255).

Click theFile menu and selectSave guestbook.

Right-click thetestdb table underDatabases and selectNew Query.

Enter the following two INSERT statements into theSQL query text windowand click theExecute button.
INSERTINTOguestbook(guestName,content)values('first guest','I got here!');INSERTINTOguestbook(guestName,content)values('second guest','Me too!');
As an example:

Expand theTables item under theDatabases > testdb item in theObjectExplorer window. Right-click thedbo.guestbook table and chooseSelectTop 1000 Rows.

The two records you inserted are displayed asResults, along with the SQLSELECT statement used to query the records.

Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
In the Google Cloud console, go to theCloud SQL Instances page.
- Select the
myinstanceinstance to open theInstance details page. - In the icon bar at the top of the page, clickDelete.
- In theDelete instance window, type your instance's name and then clickDelete.
Optional cleanup steps
If you're not using the APIs that were enabled as part of this quickstart, youcan disable them.
- APIs that were enabled within this quickstart:
- Cloud SQL Admin API
In the Google Cloud console, go to theAPIs page.
Select the Cloud SQL Admin API and then click theDisable API button.
What's next
Learn aboutcreating Cloud SQL instances.
Learn about creatingSQL Server users anddatabases for your Cloud SQL instance.
See theCloud SQL pricing information.
In this quickstart you connected to the instance by using Cloud Shell.Learn about all of theconnectivity options in Cloud SQL.How you connectdepends on your networking configuration, such as if your Cloud SQL instancehas a public or private IP address. See how toconfigure your Cloud SQL instance with apublic IP and aprivate IP address.
Learn about connecting to a Cloud SQL instance from other Google Cloudapplications:
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-24 UTC.