Stream your data: On-Prem MS-SQL to CloudSQL SQL Server to BigQuery (Part-1)

Ravish Garg
Jun 8 · 4 min read

Part1: Online replication from On-Prem MS-SQL to CloudSQL SQL Server

Why the need?

Legacy versions of enterprise relational databases have been an integral part of our application stack but as the organizations are transitioning into the digital era, they start realizing the value of untapped data and the plethora of opportunities they are missing. Thus, most organizations now looking for efficient ways to integrate their data-sources with next-gen cloud-native data warehouse platforms leveraging batch or streaming pipelines.

As per Harvard Business Review, Cross-industry studies show that on average, less than 50% of an organisation’s structured data is actively used in making decision.

In this multi-part blog, I’ll walk you through an end-to-end scenario of building a data-pipeline from a legacy SQL Server to BigQuery.

Scenario: A cost-sensitive customer, who has SQL Server 2014 standard edition and looking to build a CDC pipeline to their warehouse platform i.e. BigQuery.

By SELİM ARDA ERYILMAZ on Unsplash

Challenge: SQL Server 2014 Standard Edition does not support CDC by default and thus, either customer needs to upgrade to the 2016 standard edition or SQL Server 2014 Enterprise Edition. Later is not feasible since the customer is very cost-sensitive and the former option requires 1 to 2 months to fully test its application and that can lead to loss of potential opportunities due to lack of timely analytics.

Mitigation: Google CloudSQL for SQL Server supports transactional replication and thus, customers can sync all required tables/databases from legacy SQL Server databases to Google CloudSQL in real-time.

Implementation Plan: Microsoft SQL Server provides multiple replication options between SQL Server instances for use in distributed applications. For this scenario, we will implement Transactional Replication which makes the source database as publisher and all configured objects & data are applied to the Subscriber (Target) database in near real-time. The data changes are applied to the subscriber in the same order and within the same transaction boundaries as they occurred on the publisher.

Transactional Replication to CloudSQL SQL Server, By Author

To demonstrate, I have created a database named “demo” in a SQL Server 2014 Std. Edition and provisioned a Standard Edition Google CloudSQL SQL Server 2017 with database named “csqlawsub”.

Now, let’s setup a push based transactional replication by configuring distributor and publisher at source SQL Server.

Distributor Configuration at source SQL Server, By Author
Publisher Configuration, By Author

Created a table named “Leaderboard” in the “demo” database of source SQL Server and configure the publisher “demo_pub” to push all changed data of this table to subscriber @ CloudSQL instance.

Leaderboard Table DDL, By Author

Initiate the replication and test the data replication from source SQL Server to CloudSQL in near real-time state.

Replication Monitor: Publisher to Subscriber, By Author

Inserted 950 rows in “leaderboard” table in the “demo” database which got replicated to CloudSQL “csqlawsub” in near real-time.

“leaderboard” table @ source Database “Demo”, By Author
Rows replicated in “leaderboard” table @ “csqlawsub” database in CloudSQL SQL Server 2017, By Author

Without getting into SQL Server transactional replication explanation (for which you can refer to LINK). Here, I gave you a quick peek at how to set up an online replication to migrate user data from your existing SQL Server instance to Google CloudSQL in just few clicks.

Since Google CloudSQL SQL Server provides you 2017 version by default, you will get the CDC capability from standard edition itself which is a fully managed database service from Google. Now in Part-2, we will leverage on same & go through possible ways to construct our pipeline to BigQuery based on business requirements.

References:

Google Cloud - Community

Google Cloud community articles and blogs

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Ravish Garg

Written by

Customer Engineer, Data Specialist @ Google Cloud. I assist customers transform & evolve their business via Google’s global network and software infrastructure.

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store