因为数据库字段属性差异导致【将截断字符串或二进制数据。】,Mysql与SQL Server之间导数的字段关系需要参照下表进行设置:
Integer
MySQL | MS SQL Server | Conversion remarks |
---|
TINYINT | tinyint | tinyint is unsigned |
SMALLINT | smallint | - |
MEDIUMINT | int | int stores data on 4 bytes |
INT |
BIGINT | bigint | - |
Decimal
MySQL | MS SQL Server | Conversion remarks |
---|
DECIMAL(M,D) | decimal(p,s) | The maximum precision is 38, while the default is 18. The default scale is 0. |
浮点或双精度数据类型用于精度大于38的小数。
Advertisement
Floating Point
MySQL | MS SQL Server | Conversion 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
MySQL | MS SQL Server | Conversion 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 | - |
MS SQL Server不能将零存储为月份或日期。
String
MySQL | MS SQL Server | Conversion 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 |
字符串常量中的\'转义序列应替换为双引号字符。
Binary
MySQL | MS SQL Server | Conversion 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 |