Difference Between VARCHAR and NVARCHAR

Difference between VARCHAR and NVARCHAR are following:

1.       Data Store : A VARCHAR column is restricted to an 8-bit codepage while An NVARCHAR column can store any Unicode data.

2.       Performance : A VARCHAR column is slow to read or write to the database while A NVARCHAR is fast because all modern operating systems and development platforms use Unicode internally. By using NVARCHAR rather than VARCHAR, you can avoid doing encoding conversions every time you read from or write to the database. Conversions take time, and are prone to errors. And recovery from conversion errors is a non-trivial problem.

3.       Size :  VARCHAR can hold up to 2^31 bytes of data, or 2,147,483,648 characters; NVARCHAR(MAX) can hold 2^30 bytes, or 1,073,741,823 characters.

4.       Memory : NVARCHAR take twice space compare VARCHAR.

5.       Use: NVARCHAR uses for multi-lingual site. So always use NVARCHAR rather than VARCHAR. 

EXAMPLE: 

1.       Create a Table 

CREATE TABLE CountryInfo

(

          Name VARCHAR(50),

          StateName NVARCHAR(50)

)

2.       Insert a Row

2.PNG 

3.       Show Table Data 

SELECT Name,StateName FROM CountryInfo

1.PNG