I believe the confusion stems from a misunderstanding of the terms here.
nvarchar(n) is a data type where n can be a number from 1 to 1000. The number n in this case has a maximum of 4000, which adds up to 8000 bytes (2 bytes per character).
nvarchar(MAX) is a completely different data type - the MAX keyword is a literal, and it is not synonymous with any potential value n in my example above. Fields of this type have a maximum length of 2 ^ 31-1 characters or more than 1 billion, which is more than 2 billion bytes (2 bytes per character).
The same principles apply to varchar(n) and varchar(MAX) , except that each character can only be 1 byte, in which case the number of characters that can be stored is double. Whether this is only 1 byte depends on the sort, as Martin Smith notes in a comment!
source share