In MS SQL Server, there are some data types of string, like char, nchar, varchar, nvarchar. What’s the difference among them?
Char is fixed length. Even if you don’t use up all the space, it will still reserve the un-used space.
Varchar is flexible, it will not reserve the un-used space.
For example, if we set the length to 10: char(10), varchar(10), and we set the value to ‘apple’:
The stored data for Char(10) is: ‘apple ‘.
The stored data for Varchar(10) is: ‘apple’.
Char and Varchar cannot store Unicode characters.
‘n’ means it can store Unicode characters such as: nchar and nvarchar.
You can have a quick reference:
|Data Type||Can store unicode||Fixed-length|