Microsoft SQL Server (MS SQL) to Databricks Migration

SQLines tools can help you convert database schema (DDL), views, queries and SQL scripts from Microsoft SQL Server (MSSQL, MS SQL), Azure SQL Database, Azure Synapse to Databricks.

Databases:

  • Microsoft SQL Server 2022, 2019, 2017, 2016, 2014, 2012, 2008, 2005 and 2000
  • Databricks

Migration Reference

Identifiers

Converting identifiers:

SQL Server Databricks
1 [name] Quoted identifier `name`
2 expr AS [alias] Quoted column or table alias expr AS `alias` Backticks `` only
expr AS 'alias'
expr AS "alias"

Built-in SQL Functions

Converting datetime functions:

SQL Server Databricks
1 CONVERT(DATE, string) Convert string to date CAST(string AS DATE)
2 DATEDIFF(units, start, end) Get datetime difference in specified units DATEDIFF(units, start, end)
3 DATEFROMPARTS(year, month, day) Create DATE from fields MAKE_DATE(year, month, day)
4 DAY(datetime) Get the day of datetime DAY(datetime)
5 EOMONTH(datetime) Get the last day of the month of datetime LAST_DAY(datetime)
6 FORMAT(datetime, format) Convert to string with format DATE_FORMAT(datetime, format)
7 YEAR(datetime) Get the year of datetime YEAR(datetime)

NULL handling functions:

SQL Server Databricks
1 ISNULL(exp, replace) Replace NULL IFNULL(exp, replace)

ALTER VIEW Statement

Converting the ALTER VIEW statement:

SQL Server Databricks
1 ALTER VIEW name AS query Change the existing view ALTER VIEW name AS query

SELECT Statement

Converting SQL queries:

SQL Server Databricks
1 UNPIVOT clause Unpivoting columns into rows UNPIVOT clause

USE Statement

Converting the USE statement:

SQL Server Databricks
1 USE name Set the current database USE CATALOG name