NVARCHAR Data Type - SQL Server to MySQL Migration

In SQL Server, the NVARCHAR(n) data type stores variable-length Unicode UCS-2 or UTF-16 character strings up to n byte-pairs with the maximum of 4,000 byte-pairs or 2 GB if NVARCHAR(max) is specified.

In MySQL, you can use NVARCHAR(n), which can store up to 65,535 characters. However, the effective maximum length is subject to the maximum row size limit of 65,535 bytes (shared among all columns) and the character set used.

SQL Server:

  CREATE TABLE specs
  (
    item   NVARCHAR(30),
    name NVARCHAR(100),
    notes  NVARCHAR(MAX)
  );

MySQL:

  CREATE TABLE specs
  (
    item   NVARCHAR(30),
    name  NVARCHAR(100),
    notes  LONGTEXT
  );
  /* Query OK, 2 warnings */
  /* Warning: 3720 NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3,
       which will be replaced by UTF8MB4 in a future release. Please consider using 
       CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous. */
 
  -- NVARCHAR is implemented as VARCHAR with CHARACTER SET UTF8
  SHOW CREATE TABLE specs;
  /* CREATE TABLE `specs` (
       `item` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
       `name` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
       `notes` longtext
     ) ... */

Overview

Conversion summary:

SQL Server MySQL
Syntax NVARCHAR[(n)] NVARCHAR(n)
Parameter n is the number of byte-pairs n is the number of characters
Range 1 ⇐ n ⇐ 4,000 or 2 GB if MAX is specified 0 ⇐ n ⇐ 65,535 (with 65,535 bytes row limit )
Default n is 1 n must be specified

For more information, see SQL Server to MySQL Migration.