Overview

Unfortunately MySQL and MS SQL Server use slightly different data types, so you will have to do some 

mapping to get the correct data after the migration. This chapter describes the most important data types in

MySQL and their equivalents or recommended migration targets in SQL Server.

 

Explanation

The following tables show you the mapping of data types for data migration.

 

Integer

MySQLMS SQL ServerConversion remarks
TINYINT tinyint tinyint is unsigned
SMALLINT smallint -
MEDIUMINT int int stores data on 4 bytes
INT
BIGINT bigint -

 

Decimal

MySQLMS SQL ServerConversion remarks
DECIMAL(M,D) decimal(p,s) The maximum precision is 38, while the default is 18. The default scale is 0.

 

You can use the float or double data types for decimals with a precision greater than 38.

 

Floating Point

MySQLMS SQL ServerConversion remarks
FLOAT(N) float(n) -
FLOAT(M,D) float(24) SQL Server does not allow the non-standard syntax
DOUBLE(M,D) float(53) SQL Server does not allow the non-standard syntax
REAL(M,D)

 

Date and Time

MySQLMS SQL ServerConversion remarks
DATETIME datetime2 Date values start at 0001-01-01
DATE date Date values start at 0001-01-01
TIME time timerange is 00:00:00.0000000 through 23:59:59.9999999
TIMESTAMP smalldatetime smalldatetime value range is 1900-01-01 through 2079-06-06
YEAR smallint -

 

Please note that MS SQL Server cannot store zeros as month or day. You can read more about SQL Server

2008 Date and Time Data Types in this tip.

 

String

MySQLMS SQL ServerConversion remarks
CHAR nchar(n) nchar allows 4000 characters
VARCHAR nvarchar(n|max) nvarchar allows 4000 characters but max indicates maximum storage size of 2^31-1 bytes.
TINYTEXT
TEXT(M)
MEDIUMTEXT
LONGTEXT

 

\’ escape sequences in string constants should be replaced by double quote characters.

Binary

MySQLMS SQL ServerConversion remarks
BINARY(M) binary(n) binary allows 8000 bytes
VARBINARY(M) varbinary(n|max) nvarbinary allows 8000 bytes but max indicates maximum storage size of 2^31-1 bytes.
TINYBLOB
BLOB
MEDIUMBLOB
LONGBLOB

 

 

Reference:https://www.mssqltips.com/sqlservertutorial/2203/mysql-to-sql-server-data-type-comparisons/

Reference:https://dev.mysql.com/doc/workbench/en/wb-migration-database-mssql-typemapping.html

arrow
arrow
    文章標籤
    [MySQL]
    全站熱搜

    mitblog 發表在 痞客邦 留言(0) 人氣()