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
INT AUTO_INCREMENTINT IDENTITY(1,1)IDENTITY replaces AUTO_INCREMENTVARCHAR(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 textTINYINT(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 DATETIMETIMESTAMPROWVERSION or DATETIME2SQL Server TIMESTAMP is a rowversion (not datetime); use DATETIME2 for timestampsBLOBVARBINARY(MAX)VARBINARY(MAX) stores binary data up to 2GBJSONNVARCHAR(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 constraintDECIMAL(p,s)DECIMAL(p,s) or NUMERIC(p,s)Identical behaviorSQL Syntax Differences
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
MySQL
INT AUTO_INCREMENT
SQL Server
INT IDENTITY(1,1)
IDENTITY columns are created with seed and increment: IDENTITY(start, step)
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
MySQL
IFNULL(col, 'default')
SQL Server
ISNULL(col, 'default') or COALESCE(col, 'default')
ISNULL is T-SQL specific; COALESCE is ANSI standard
MySQL
CONCAT(), SUBSTRING(), LENGTH()
SQL Server
CONCAT(), SUBSTRING(), LEN()
LENGTH() in MySQL = LEN() in T-SQL
MySQL
NOW(), DATE_FORMAT(), DATEDIFF()
SQL Server
GETDATE()/SYSDATETIME(), FORMAT(), DATEDIFF()
DATEDIFF takes a datepart argument in T-SQL: DATEDIFF(day, date1, date2)
MySQL
Not natively supported (UNION workaround)
SQL Server
Natively supported: FULL OUTER JOIN
T-SQL supports all JOIN types
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
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
Convert Schema with SSMA
Connect SSMA to both MySQL source and SQL Server target. Run schema conversion to get an automatically converted DDL script.
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).
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
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
FREESQL Server Migration Assistant — Microsoft's free tool for MySQL to SQL Server migration.
SQL Server Management Studio (SSMS)
FREEFree SQL Server IDE for schema management and query testing.
BCP utility
FREEBulk 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?
What is the biggest challenge when migrating from MySQL to SQL Server?
Ready to Migrate?
Test your SQL Server queries in our free SQL Playground before migrating.