First, char, varchar, and nvarchar, text, and ntext are all text data types in the database, then differentiate between the Var prefix and the n prefix. Text and ntext have been generally replaced by varchar (max) and nvarchar (max), so they are not generally used.
Char
Represents an immutable length, and if the assigned value is not sufficient to specify the number of digits, the end is padded with spaces.
varchar
Represents a variable length, if the assigned value is not sufficient to specify the number of digits, the actual assigned value will prevail.
nvarchar
The n prefix represents the Unicode encoding standard. If it is with N, then each character occupies 2 bytes. If you do not have n, the English character occupies 1 bytes, and the Chinese byte is two bytes (that is, Unicode encoding format). commonly used in the development process is nvarchar rather than varchar, is to avoid the compatibility of Chinese and English.
When it is possible to accurately control the length of text bytes, using char is more efficient than using nvarchar, reducing the time cost of calculating text length and increasing the storage cost (but it is not a big problem in the case of low storage costs).
The difference between char, varchar, and nvarchar