Here are the differences between the datatypes:
Character data types that are either fixed-length, nchar, or variable-length, nvarchar, Unicode data and use the UNICODE UCS-2 character set.
- nchar [(n)] : Fixed-length Unicode character data of n characters. n must be a value from 1 through 4000. The storage size is two times n bytes. The ISO synonyms for nchar are national char and national character;
- char[(n)] : Fixed-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8000. Storage size is n bytes. The SQL-92 synonym for char is character;
- varchar[(n)] : Variable-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8000. Storage size is the actual length in bytes of the data entered, not n bytes. The data entered can be 0 characters in length. The SQL-92 synonyms for varchar are char varying or character varying;
- nvarchar [(n|max)] : Variable-length Unicode character data. n can be a value from 1 through 4000. max indicates that the maximum storage size is 231-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for nvarchar are national char varying and national character varying.
[N]CHAR VS. [N]VARCHAR data types: few considerations for usage and performance
- Always specify the narrowest columns you can. The narrower the column, the less amount of data SQL Server has to store, and the faster SQL Server is able to read and write data. In addition, if any sorts need to be performed on the column, the narrower the column, the faster the sort will be.
- Don’t use the NVARCHAR or NCHAR data types unless you need to store 16-bit character (Unicode) data. They take up twice as much space as VARCHAR or CHAR data types, increasing server I/O and wasting unnecessary space in your buffer cache.
- If a column’s data does not vary widely in length, consider using a fixed-length CHAR field instead of a VARCHAR. While it may take up a little more space to store the data, processing fixed-length columns is faster in SQL Server than processing variable-length columns.
- If you are using fixed length columns (CHAR, NCHAR) in your table, consider avoiding storing NULLs in them. If you do, the entire amount of space dedicated to the column will be used up.