Greg Larsen compares CHAR, VARCHAR, and VARCHAR(MAX):
In every database, there are different kinds of data that need to be stored. Some data is strictly numeric, while other data consists of only letters or a combination of letters, numbers, and even special symbols. Whether it is just stored in memory or on disk, each piece of data requires a data type. Picking the correct data type depends on the characteristics of the data being stored. This article explains the differences between
CHAR
,VARCHAR
, andVARCHAR(MAX)
.
Click through for Greg’s explanation. My official rule of thumb is as follows:
- If you have a fixed-length code which you display to customers, use NCHAR.
- If you have a fixed-length code which you only use internally and you know that the code will never include characters outside of your SQL Server installation’s code page and you know that the code page will never change…probably still use NCHAR, though if you twist my arm enough I’d say fine, CHAR.
- Otherwise, use NVARCHAR.
Three decades ago, the choice was a lot trickier given performance differences between the two. Today? Unless you’re hunting for microseconds I don’t think you’ll see a practical difference. And if you are hunting for microseconds, you probably want more than rules of thumb.