Difference between Varchar and Nvarchar. When to use what?

Character datatypes come in four varieties. They can be fixed-length or variable-length single-byte character strings (char and varchar) or fixed-length or variable-length Unicode characters strings (nchar and varchar).

Varchar stores ASCII values and Nvarchar stores Unicode characters.

Varchar can store up to 8000 characters, and Unicode character strings can store up to 4000 characters.

It is important to know the type of data you’ll be dealing with in order to decide between single-byte and double-byte character strings.

If you have requirements to store UNICODE or multilingual data, something that uses Chinese, Japanese or Korean character set, you are better off using nvarchar.

To put this in perspective, see the example below where VARCHAR and NVARCHAR character datatypes are being used.

In the first image, varchar uses single-byte storage whereas the second image nvarchar datatype uses double-byte character strings.


Even though, varchar and nvarchar are more or less the same, the key difference between the two is that varchar stores ASCII characters whereas nvarchar stores Unicode characters. Unicode characters are typically associated with languages such as Japanese, Korean, Chinese etc.

About Obi Oberoi

Obi Oberoi is a Microsoft MVP (Visual Studio & Development Technologies), developer and a life-long student of continuous learning. Obi enjoys to code, read, and hang out with techies and geeks!
This entry was posted in SQL Server. Bookmark the permalink.