Wednesday, 16 July 2014

Difference between VARCHAR and NVARCHAR datatypes in SQL Server.



The only difference is that NVARCHAR can handle unicode characters, allowing you to use multiple languages in the database (Arabian, Chinese, etc.). NVARCHAR takes twice as much space when compared to VARCHAR. Use NVARCHAR only if you are using foreign languages.
Varchar
NVarchar
Non-Unicode Variable Length character data type.
UNicode Variable Length character data type. It can store both non-Unicode and Unicode (i.e. Japanese, Korean etc) characters.
It takes 1 byte per character
It takes 2 bytes per Unicode/Non-Unicode character.
Optional Parameter n value can be from 1 to 8000.Can store maximum 8000 Non-Unicode characters.
Optional Parameter n value can be from 1 to 4000.Can store maximum 4000 Unicode/Non-Unicode characters
If Optional parameter value n is not specified in the variable declaration or column definition then it is considered as 1.
If Optional parameter value n is not specified in the variable declaration or column definition then it is considered as 1.

No comments:

Post a Comment