Saturday 26 September 2015

Difference Between NVarchar and Varchar in SQL Server

Below list is major difference between Varchar[n] and NVarchar[n] Datatype in Sql Server;


Type
nVarchar[n]
Varchar[n]
Storage Type
It store both Non Unicode and Unicode data e.g. it store the Hindi, Chinese etc.  Language.

e.g.
DECLARE @Name AS VARCHAR(50) =短发

  SELECT @Name
It store the Non Unicode character.

e.g.
DECLARE @Name AS VARCHAR(50) =‘Bob’
SELECT
 @Name
Maximum Storage
It store maximum 4000 Unicode and Non-Unicode character.
It store maximum  8000  Non-Unicode character
Bytes Required for Each character
It store 1 Byte per Character.
It store 2 byte per character either it is Unicode or non Unicode.
Which should Use
 Data can have Unicode characters.
Data doesn’t have any Unicode characters.


No comments:

Post a Comment