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:
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" | ||||
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) |
Converting the ALTER VIEW statement:
| SQL Server | Databricks | ||
| 1 | ALTER VIEW name AS query | Change the existing view | ALTER VIEW name AS query |
Converting SQL queries:
| SQL Server | Databricks | ||
| 1 | UNPIVOT clause | Unpivoting columns into rows | UNPIVOT clause |
Converting the USE statement:
| SQL Server | Databricks | ||
| 1 | USE name | Set the current database | USE CATALOG name |