You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Character data types that are either fixed-length, **nchar**, or variable-length, **nvarchar**, Unicode data and use the UNICODE UCS-2 character set.
24
+
Character data types that are either fixed-length, **nchar**, or variable-length, **nvarchar**. Starting with [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], when a [Supplementary Character (SC)](../../relational-databases/collations/collation-and-unicode-support.md#Supplementary_Characters) enabled collation is used, these data types store [Unicode](../../relational-databases/collations/collation-and-unicode-support.md#Unicode_Defn) data and use the UNICODE UTF-16 character set. If a non-SC collation is specified, then these data types store Unicode string data and use the UNICODE UCS-2 character set.
25
25
26
26
## Arguments
27
27
**nchar**[ ( n ) ]
28
28
Fixed-length Unicode string data. *n* defines the string length and must be a value from 1 through 4,000. The storage size is two times *n* bytes. When the collation code page uses double-byte characters, the storage size is still *n* bytes. Depending on the string, the storage size of *n* bytes can be less than the value specified for *n*. The ISO synonyms for **nchar** are **national char** and **national character**.
29
29
30
30
**nvarchar**[ ( n | **max** ) ]
31
-
Variable-length Unicode string data. *n* defines the string length and can be a value from 1 through 4,000. **max** indicates that the maximum storage size is 2^30-1 characters. The maximum storage size in bytes is 2 GB. The actual storage size, in bytes, is two times the number of characters entered + 2 bytes. The ISO synonyms for **nvarchar** are **national char varying** and **national character varying**.
31
+
Variable-length Unicode string data. *n* defines the string length and can be a value from 1 through 4,000. **max** indicates that the maximum storage size is 2^30-1 characters (2 GB). The storage size is two times *n*bytes + 2 bytes. When the collation code page uses double-byte characters, the storage size is still *n*bytes + 2 bytes. Depending on the string, the storage size of *n* bytes can be less than the value specified for *n*. The ISO synonyms for **nvarchar** are **national char varying** and **national character varying**.
32
32
33
33
## Remarks
34
34
When *n* is not specified in a data definition or variable declaration statement, the default length is 1. When *n* is not specified with the CAST function, the default length is 30.
35
-
36
-
Use **nchar** when the sizes of the column data entries are probably going to be similar.
37
-
38
-
Use **nvarchar** when the sizes of the column data entries are probably going to vary considerably.
35
+
36
+
If you use **char** or **varchar**, we recommend the following:
37
+
- Use **nchar** when the sizes of the column data entries are consistent.
38
+
- Use **nvarchar** when the sizes of the column data entries vary considerably.
39
+
- Use **nvarchar(max)** when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes.
39
40
40
41
**sysname** is a system-supplied user-defined data type that is functionally equivalent to **nvarchar(128)**, except that it is not nullable. **sysname** is used to reference database object names.
0 commit comments