MySQL to Microsoft SQL Server Migration

SQLines tools can help you transfer data, convert database schema (DDL), views, stored procedures and functions, triggers, SQL queries and SQL scripts from MySQL to Microsoft SQL Server (MS SQL, MSSQL), Azure SQL and Azure Synapse.

Databases

  • MySQL 8.x and 5.x
  • Microsoft SQL Server 2022, 2019, 2017, 2016, 2014, 2012, 2008 and 2005

Migration Reference

Identifiers

Converting identifiers:

MySQL SQL Server
Quoted Identifiers ` (backtick) and " (double quotes) [ ] and " (double quotes)

Data Types

Converting numeric data types:

MySQL SQL Server
1 BIGINT 64-bit integer BIGINT
2 DECIMAL(p,s) Fixed-point number, p <= 65 DECIMAL(p,s) p <= 38
3 DEC(p,s) Synonym for DECIMAL DEC(p,s)
4 DOUBLE [PRECISION] Double-precision floating-point number FLOAT
5 FIXED(p,s) Synonym for DECIMAL DECIMAL(p,s)
6 FLOAT(p) Floating-point number FLOAT
7 FLOAT4(p) Floating-point number FLOAT
8 FLOAT8 Double-precision floating-point number BINARY_DOUBLE
9 INT, INTEGER 32-bit integer INT, INTEGER
10 INT1 8-bit integer SMALLINT
11 INT2 16-bit integer SMALLINT
12 INT3 24-bit integer INT
13 INT4 32-bit integer INT
14 INT8 64-bit integer BIGINT
15 MEDIUMINT 24-bit integer INT
16 MIDDLEINT 24-bit integer INT
17 NUMERIC(p,s) Synonym for DECIMAL NUMERIC(p,s)
18 REAL Double-precision floating-point number DOUBLE PRECISION
19 SERIAL 64-bit autoincrementing integer NUMERIC(20)
20 SMALLINT 16-bit integer SMALLINT
21 TINYINT 8-bit integer SMALLINT

Converting other data types:

MySQL SQL Server
1 BINARY(n) Fixed-length byte string, 1 ⇐ n ⇐ 255 BINARY(n)
2 BIT(n) Fixed-length bit string, 1 <= n <= 64 BINARY(n/8)
3 BLOB(n) Binary large object, ⇐ 64K VARBINARY(max)
4 BOOLEAN, BOOL 0 or 1 value; NULL is not allowed BIT
5 CHAR(n), CHARACTER(n) Fixed-length string, 1 ⇐ n ⇐ 255 CHAR(n), CHARACTER(n)
6 CHARACTER VARYING(n) Variable-length string, 1 ⇐ n ⇐ 65535 CHARACTER VARYING(n)
7 DATE Date (year, month and day) DATE Since SQL Server 2008
8 DATETIME(p) Date and time data with fraction DATETIME2(p)
9 LONGBLOB Binary large object, ⇐ 4G VARBINARY(max)
10 LONGTEXT Character large object, ⇐ 4G VARCHAR(max)
11 LONG VARBINARY Binary large object, ⇐ 16M VARBINARY(max)
12 LONG, LONG VARCHAR Character large object, ⇐ 16M VARCHAR(max)
13 MEDIUMBLOB Binary large object, ⇐ 16M VARBINARY(max)
14 MEDIUMTEXT Character large object, ⇐ 16M VARCHAR(max)
15 NCHAR(n) Fixed-length UTF-8 string, 1 ⇐ n ⇐ 255 NCHAR(n)
16 NVARCHAR(n) Varying-length UTF-8 string, 1 ⇐ n ⇐ 65535 NVARCHAR(n)
17 TEXT Character large object, ⇐ 64K VARCHAR(max)
18 TIME(p) Time (Hour, minute, second and fraction) TIME(p)
19 TIMESTAMP(p) Auto-updated datetime DATETIME2(p)
20 TINYBLOB Binary data, ⇐ 255 bytes VARBINARY(255)
21 TINYTEXT Character data, ⇐ 255 bytes VARCHAR(255)
22 VARBINARY(n) Variable-length byte string, 1 ⇐ n ⇐ 65535 VARBINARY(n)
23 VARCHAR(n) Variable-length string, 1 ⇐ n ⇐ 65535 VARCHAR(n)
24 YEAR[(2 | 4)] Year in 2-digit or 4-digit format NUMERIC(4)

Data Type Attributes:

MySQL SQL Server
Display width for integers INT(d) Not supported
UNSIGNED CHECK (col_name > 0)
AUTO_INCREMENT IDENTITY
COLLATE collate_name
CHARACTER SET charset_name
COMMENT 'string'
ON UPDATE clause for TIMESTAMP columns Not supported
BINARY(0) BINARY(1)

Built-in SQL Functions

Converting functions:

MySQL SQL Server
1 CURRENT_TIMESTAMP CURRENT_TIMESTAMP() Get current date and time GETDATE()

CREATE TABLE Statement

Converting table definitions:

MySQL SQL Server
1 UNIQUE KEY | INDEX name (column, …) CONSTRAINT name UNIQUE (column, …)
2 KEY name (column, …) Inline non-unique index CREATE INDEX name ON table(column, …) Standalone statement

SELECT Statement

Converting SQL queries:

MySQL SQL Server
1 SELECT … FROM … LIMIT n Select n rows only SELECT TOP n … FROM …

CREATE PROCEDURE Statement

Converting stored procedures:

MySQL SQL Server
1 CREATE PROCEDURE name CREATE PROCEDURE name
2 DEFINER = user Removed
3 IN | OUT | INOUT param datatype(len) Parameter definition @param datatype(len) OUT | OUTPUT
4 No AS keyword before outer BEGIN END block AS keyword required
5 User-defined delimiter at the end GO