SQL Server – Difference between VARCHAR and NVARCHAR datatypes

Difference between VARCHAR and NVARCHAR datatypes

Recently I asked my friend who works as a junior DBA for last 6 months, the difference between VARCHAR and NVARCHAR datatypes. He told me that there is a minor difference between them and we don’t need to really bother about it.

Like my friend it may be a case with many people, who are not sure about the exact difference between VARCHAR and NVARCHAR datatypes. And they use them interchangeably.

VARCHAR is the abbreviation for VARiable-length CHARacter string. It can store upto 8000 characters. It uses one byte to store one character.

NVARCHAR is the abbreviation for uNnicode VARiable-length CHARacter string. It can store upto 4000 characters. It uses two bytes to store one character. NVARCHAR is nothing more then VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is mixture of English and non-English symbols.

The amount of storage needed for NVARCHAR entities is twice the storage needed for VARCHAR entities.

Tip – Avoid using NVARCHAR and use VARCHAR when you know that the data which need to be stored will never constitute of non-English characters.

Good Luck!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: