Difference between varchar and nvarchar

The wide range of data types in MS SQL Server can sometimes throw people through a loop, especially when the data types look highly interchangeable. VARCHAR and NVARCHAR seem to be highly interchangeable but there is some sort of difference between them. Let’s discuss it.

Difference between varchar and nvarchar

VARCHAR is an abbreviation for variable-length character string. It is a string of text characters that can be as large as the page size for the database table holding the column in question. Normally the size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. So the maximum size of a VARCHAR is 8,000 bytes. Varchar stores ascii data.

The additional "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is identical to VARCHAR but it supports two-byte characters. The most common use for this type of thing is to store character data that is a mixture of English and non-English symbols such as English and Chinese. Simply nvarchar stores unicode data and takes twice space than varchar

So that's it. I love your feedback.

0 comments: