Try out SQL Server on Google Cloud at your own pace

Jonathan Simon
Google Cloud - Community
5 min readFeb 20, 2020

Here’s an affordable way to try out SQL Server on Google Cloud at your own pace.

We’re going to walk through the steps required to create a Google Cloud Platform project and start up a Cloud SQL for SQL Server instance. Next, we’ll use Azure Data Studio to create a database with a single table, insert some sample data into the table and then confirm that we can query data from the new table. Finally we’ll shutdown the SQL Server to stop getting charged for it until we’re ready to use it again.

Create a Google Cloud Platform project

To get started, we’ll need a Google Cloud Platform project. If you already have a project, you can skip this step. Follow the documentation for creating and managing projects to create a new project.

Create a SQL Server instance

Once your project is created click the Cloud Console’s left-menu and select “SQL” to open the Cloud SQL view. Now we can create our instance.

Click the “Create Instance” button and select the “Choose SQL Server” option.

Enter “myinstance” for Instance ID.

Enter a password for the “sqlserver” user or click the “Generate” button.

Use the default values for the other fields.

Click the “Create” button.

Create SQL Server Instance

You are returned to the instances list; you can click into the new instance right away to see the details, but it won’t be available until it initializes and starts.

Setup your connection using Google Cloud SDK and the Cloud SQL Proxy

Once the instance is created, we need to setup Google Cloud SDK and the Cloud SQL Proxy which will allow us to connect to the instance via common database management tools like SQL Server Management Studio or Azure Data Studio. Follow these steps to setup Google Cloud SDK and the Cloud SQL Proxy:

  1. Install the Cloud SDK. The Cloud SDK provides the gcloud tool to interact with Cloud SQL and other Google Cloud services. The gcloud tool uses the Cloud SQL ADmin API to access Cloud SQL, so you must Enable the API before using the gcloud tool to access Cloud SQL.

2. In a bash shell command prompt or in PowerShell, run the following command to initialize the gcloud tool:

gcloud init

3. Run the following command to authenticate the gcloud tool:

gcloud auth login

4. Download and install the Google Cloud SQL Proxy (see Installing the Cloud SQL Proxy). Note the location where you saved the Cloud SQL Proxy executable, because you will run the proxy in the next step.

5. Run the Cloud SQL Proxy using a bash shell command prompt or PowerShell, replacing “[Instance-connection-name]” with the corresponding value from the Cloud Console’s Overview tab (for your instance):

./cloud_sql_proxy -instances=[Instance-connection-name]=tcp:1433

For more information about installing and using the proxy, see About the Cloud SQL Proxy.

Connect to your instance using Azure Data Studio

With the Cloud SQL Proxy running, connect to your SQL Server instance using Azure Data Studio and the localhost IP address:

Click the “New Connection” option in Azure Data Studio

Enter the following values in the Connection Details dialog:

  1. For Connection Type, enter Microsoft SQL Server.
  2. For Server, enter 127.0.0.1 as the IP address of your SQL Server instance.
  3. For Authentication type, enter SQL Login.
  4. For User name, enter sqlserver.
  5. For Password, enter the password used when the instance was created.

Once we’re connected to the SQL Server instance, we can create a Database and a Table to try things out. Right click the server in Azure Data Studio and select “New Query”.

Enter the following query into the New Query window.

CREATE DATABASE testdb;
GO
USE testdb;
GO
CREATE TABLE guestbook (
entryID int IDENTITY(1, 1) NOT NULL PRIMARY KEY,
guestname varchar(255),
content varchar(255)
);

Click the “Run” button at the top of the query editor.

Right-click the newly created testdb table listed under Databases and select “New Query”.

Enter the following INSERT statements and click the “Run” button to run the SQL Statements:

INSERT INTO guestbook (guestname, content) values (‘first guest’, ‘I got here!’);INSERT INTO guestbook (guestname, content) values (‘second guest’, ‘Me too!’);

Now that we’ve inserted some data let’s query the table to confirm that we can access the data.

Expand the Tables item under the Databases > testdb item left nav menu. Right-click the dbo.guestbook table and choose “Select Top 1000 Rows”.

The two records you inserted are displayed as results, well done!

Shutting down the Instance

Shutting down the instance ensures that any charges billed for the instance stop until it is restarted. When you’re ready to start using it again, simply click the instance’s “Start” button to restart the instance.

See Doug Mahugh’s blog post for more about getting started. Also check out the blog post Migrate your Microsoft SQL Server workloads to Google Cloud and the SQL Server documentation for more information about getting your applications connected to a Google Cloud Platform SQL Server.

--

--