intermediate 1-3 weeks for typical application databases100% Free Guide

How to Migrate from MySQL to SQL Server

Migrating from MySQL to Microsoft SQL Server involves converting MySQL's SQL dialect to T-SQL, adapting data types, and porting MySQL-specific features to their SQL Server equivalents. SQL Server's T-SQL is feature-rich but has significant syntax differences from MySQL's SQL.

10

Data Type Mappings

8

Syntax Differences

5

Migration Steps

3

Free Tools

Data Type Mappings

MySQLSQL ServerNotes
INT AUTO_INCREMENTINT IDENTITY(1,1)IDENTITY replaces AUTO_INCREMENT
VARCHAR(n)NVARCHAR(n) or VARCHAR(n)Use NVARCHAR for Unicode support (recommended for internationalization)
TEXT / MEDIUMTEXT / LONGTEXTVARCHAR(MAX) or NVARCHAR(MAX)SQL Server uses (MAX) for unlimited text
TINYINT(1) (boolean)BITBIT is SQL Server's boolean type (0/1/NULL)
DATETIMEDATETIME2DATETIME2 has more precision and a wider range than SQL Server's legacy DATETIME
TIMESTAMPROWVERSION or DATETIME2SQL Server TIMESTAMP is a rowversion (not datetime); use DATETIME2 for timestamps
BLOBVARBINARY(MAX)VARBINARY(MAX) stores binary data up to 2GB
JSONNVARCHAR(MAX) with JSON functionsSQL Server 2016+ has JSON support via OPENJSON(), JSON_VALUE(), JSON_MODIFY()
UNSIGNED INTBIGINT (or use CHECK constraint)No unsigned integers in SQL Server; use larger type or constraint
DECIMAL(p,s)DECIMAL(p,s) or NUMERIC(p,s)Identical behavior

SQL Syntax Differences

String Quoting

MySQL

Single or double quotes for strings

SQL Server

Single quotes only; square brackets [name] or double quotes for identifiers

N'unicode string' prefix for NVARCHAR literals

Auto Increment

MySQL

INT AUTO_INCREMENT

SQL Server

INT IDENTITY(1,1)

IDENTITY columns are created with seed and increment: IDENTITY(start, step)

LIMIT / OFFSET

MySQL

SELECT * FROM t LIMIT 10 OFFSET 20

SQL Server

SELECT * FROM t ORDER BY col OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY

T-SQL requires ORDER BY with OFFSET/FETCH

IFNULL

MySQL

IFNULL(col, 'default')

SQL Server

ISNULL(col, 'default') or COALESCE(col, 'default')

ISNULL is T-SQL specific; COALESCE is ANSI standard

String Functions

MySQL

CONCAT(), SUBSTRING(), LENGTH()

SQL Server

CONCAT(), SUBSTRING(), LEN()

LENGTH() in MySQL = LEN() in T-SQL

Date Functions

MySQL

NOW(), DATE_FORMAT(), DATEDIFF()

SQL Server

GETDATE()/SYSDATETIME(), FORMAT(), DATEDIFF()

DATEDIFF takes a datepart argument in T-SQL: DATEDIFF(day, date1, date2)

Full Outer Join

MySQL

Not natively supported (UNION workaround)

SQL Server

Natively supported: FULL OUTER JOIN

T-SQL supports all JOIN types

Backtick Quoting

MySQL

SELECT `col` FROM `table`

SQL Server

SELECT [col] FROM [table] or SELECT col FROM table

Replace all backticks with square brackets

Step-by-Step Migration Guide

1

Use SSMA for MySQL

Download SQL Server Migration Assistant (SSMA) for MySQL from Microsoft. It automates schema conversion and data migration.

Download free from Microsoft: SQL Server Migration Assistant for MySQL
2

Convert Schema with SSMA

Connect SSMA to both MySQL source and SQL Server target. Run schema conversion to get an automatically converted DDL script.

3

Review and Fix Conversion Report

SSMA generates a migration report with errors and warnings. Manually fix items SSMA couldn't convert automatically (complex stored procedures, MySQL-specific functions).

4

Migrate Data

Use SSMA's data migration feature or BCP (Bulk Copy Program) for large tables.

bcp source_db.dbo.tablename out data.dat -S server -U user -P pass -n
5

Test Application Queries

Run application query tests against SQL Server. Fix T-SQL syntax issues, update connection strings (use SQL Server driver), and verify stored procedure behavior.

Common Issues & Solutions

LIMIT syntax not recognized in T-SQL

Replace LIMIT n with TOP n in simple queries, or use OFFSET/FETCH for paginated queries: SELECT * FROM t ORDER BY id OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY

MySQL ENUM types not supported

Convert ENUM columns to NVARCHAR with a CHECK constraint or create a lookup table with a foreign key.

Stored procedure syntax completely different

MySQL procedures use BEGIN/END with different variable syntax. Rewrite in T-SQL: DECLARE @var DATATYPE, SET @var = value, use T-SQL control flow (IF/ELSE/WHILE).

Case sensitivity differences

SQL Server collation controls case sensitivity. Default is case-insensitive. Set the desired collation at database or column level.

Recommended Migration Tools

SSMA for MySQL

FREE

SQL Server Migration Assistant — Microsoft's free tool for MySQL to SQL Server migration.

SQL Server Management Studio (SSMS)

FREE

Free SQL Server IDE for schema management and query testing.

BCP utility

FREE

Bulk Copy Program — fast data load/export tool included with SQL Server.

Frequently Asked Questions

Is there a free tool to migrate MySQL to SQL Server?
Yes. SQL Server Migration Assistant (SSMA) for MySQL is free from Microsoft. It automates schema conversion (including data type mapping), provides a migration report highlighting issues, and handles data migration. Download it from the Microsoft Download Center.
What is the biggest challenge when migrating from MySQL to SQL Server?
The biggest challenges are: 1) Stored procedure rewrites — MySQL and T-SQL have different procedural syntax. 2) LIMIT/OFFSET → OFFSET/FETCH. 3) MySQL ENUM types require manual conversion. 4) Date function differences (NOW() → GETDATE(), DATE_FORMAT() → FORMAT()). 5) Backtick quoting → square bracket quoting.

Ready to Migrate?

Test your SQL Server queries in our free SQL Playground before migrating.