Announcing SQL Server to Snowflake Migration Solutions

It’s Spring (or at least it will be soon), and while nature may take the Winter off from growing it’s product, Mobilize.Net did not. As Snowflake continues to grow, SnowConvert continues to grow as well. Last month, Mobilize.Net announced SnowConvert for Oracle, the first follow-up to the immensely popular SnowConvert for Teradata. This month? It’s time for SnowConvert for SQL Server

SQL Server has been Microsoft’s database of choice since before Windows was in existence. It has provided a lightweight option for thousands of application’s back-end, and has evolved to be a comprehensive database platform for thousands of organizations. As an on-solution, SQL Server carried many developers and organization through the 90s and early 2000s. But like other on-prem solutions, the cloud has come. Even Microsoft has taken it’s database-ing to the cloud through Azure and Synapse. Snowflake has taken the lead as the Data Cloud, and SnowConvert is the best and most experienced way to help you get there. 

If you have SQL Server, I would hope the SQL you have written for SQL Server is not quite as old as the first version of windows. But even if it is and the architects of that original SQL are nowhere to be anymore, SnowConvert’s got you covered. SnowConvert automates any code the conversion of any DDL and DML that you may have to an equivalent in Snowflake. But that’s the easy part. The hard problem in a code migration for databases is the procedural code. That mean Transact SQL for MSSQL Server. And with T-SQL, SnowConvert again has you covered.

Procedures Transformed

SnowConvert can take your T-SQL to functionally equivalent JavaScript or Snowflake Scripting. Both our product page and documentation have more information on the type of transformation performed, so why not show you what that looks like on this page? Let’s take a look at really basic procedure from the Microsoft Adventure Works database and convert into functionally equivalent JavaScript. This is a procedure that does an update to a table: 

CREATE PROCEDURE [HumanResources].[uspUpdateEmployeePersonalInfo]
@BusinessEntityID [int],
@NationalIDNumber [nvarchar](15),
@BirthDate [datetime],
@MaritalStatus [nchar](1),
@Gender [nchar](1)
WITH EXECUTE AS CALLER
AS
BEGIN
SET NOCOUNT ON;

BEGIN TRY
UPDATE [HumanResources].[Employee]
SET [NationalIDNumber] = @NationalIDNumber
,[BirthDate] = @BirthDate
,[MaritalStatus] = @MaritalStatus
,[Gender] = @Gender
WHERE [BusinessEntityID] = @BusinessEntityID;
END TRY
BEGIN CATCH
EXECUTE [dbo].[uspLogError];
END CATCH;
END;

Pretty straightforward in SQL Server. But how do you replicate this functionality in JavaScript automatically? Of course, by using SnowConvert. Here’s the output transformation:

CREATE OR REPLACE PROCEDURE HumanResources.uspUpdateEmployeePersonalInfo (BUSINESSENTITYID FLOAT, NATIONALIDNUMBER STRING, BIRTHDATE DATE, MARITALSTATUS STRING, GENDER STRING)
RETURNS STRING
LANGUAGE JAVASCRIPT
EXECUTE AS CALLER
AS
$$
// REGION SnowConvert Helpers Code
// This section would be populated by SnowConvert for SQL Server’s JavaScript Helper Classes. If you’d like to see more of the helper classes, fill out the form on the SnowConvert for SQL Server Getting Started Page.
// END REGION

/*** MSC-WARNING – MSCEWI1040 – THE STATEMENT IS NOT SUPPORTED IN SNOWFLAKE ***/
/* SET NOCOUNT ON*/
;
try {
EXEC(` UPDATE HumanResources.Employee
SET NationalIDNumber = ?
, BirthDate = ?
, MaritalStatus = ?
, Gender = ?
WHERE BusinessEntityID = ?`,[NATIONALIDNUMBER,BIRTHDATE,MARITALSTATUS,GENDER,BUSINESSENTITYID]);
} catch(error) {
EXEC(`CALL dbo.uspLogError(/*** MSC-WARNING – MSCEWI4010 – Default value added ***/ 0)`);
}
$$;

SnowConvert creates multiple helper class functions (including the EXEC helper called in the output procedure) to recreate the functionality that is present in the source code. SnowConvert also has finely tuned error messages to give you more information about any issues that may be present. You can actually click on both of the codes in the output procedure above to see the documentation page for that error code.

Want to see the same procedure above in Snowflake Scripting? Interested in getting an inventory of code that you’d like to take the cloud? Let us know. We can help you get started and understand the codebase you’re working with. If you’re already familiar with SnowConvert in general, SnowConvert for SQL Server has all the capabilities that you’ve come to expect. From the ability to generate granular assessment data to functionally equivalent transformations built upon a semantic model of the source code, SnowConvert for SQL Server is ready to see what you can throw at it. Get started today!

Flatlogic Admin Templates banner

351: Moving to PostgreSQL from MySQL

As you read this, CodePen is 100% on PostgreSQL for our main relational database. It was a transition that took a couple weeks of pretty intense effort, and lots of planning and prep before that. I’ve got Alex on the show to talk about it, as he was the main instigator and led the effort, but everyone contributed in some way.

Wondering why? Well…

We were on a pretty old version of MySQL (5.6), and upgrading to something more modern (like 8) would have required just as much effort, so we thought we’d move on to something we saw more value in.
We’re undertaking big new efforts that require a bunch of data specific work. It’ll be more work to change after that, so it felt like a now or never situation.
PostgreSQL means consolidating of technology, which is big for our small team. We’ve done some of this, and it opens the door for more. For example, we can stop using Elasticsearch as a totally separate database for search and lean on PostgreSQL. The same goes for an analytics-focused database, job queuing, and even potentially static asset hosting.

There is a lot to talk about here, so we get into all the nitty-gritty detail, including how we pulled it off with near-zero downtime and the tools involved.

Time Jumps

00:16 CodePen switched databases

01:08 Team effort

03:16 Is it a big paradigm shift?

06:53 Using ElasticSearch

13:34 Recapping the why

16:14 We have some in house experience with PostGres

17:17 Sponsor: WooCommerce

18:50 How did we do the transition?

27:23 How long did it take to move the data?

31:14 How the migration went

36:53 What enabled this to be possible

41:06 Any negatives or issues?

Sponsor: WooCommerce

WooCommerce is eCommerce for WordPress. It’s powerful software in that it can do anything you could ever want to do in selling online. You can sell physical products. You can sell digital and downloadable products. You can sell memberships or tickets or appointments. The sky is the limit. I’ve used it personally for all those things and have had a great experience every time.

The post 351: Moving to PostgreSQL from MySQL appeared first on CodePen Blog.