Wednesday, April 24, 2013
Sql Server : Difference between varchar and nvarchar
Mainly nvarchar stores unicode characters and varchar stores non-unicodes characters.
"unicodes" means 16-bit character encoding scheme allowing characters from lots of other languages like Chinese, Japanese etc, to be encoded in a single character set.
That means unicodes is using 2 bytes per character to store and nonunicodes uses only 1 byte per character to store.
Example:Take French Language, in French Language Désolé can not be stored in varchar datatype The difference as indicated by the N prefix is that the N datatypes use a unicode codeing system for data.
If you are not storing the other language characters like French, Portuguese then both data type are same. varchar datatype should be used instead. The reason for this is that nvarchar takes twice as much space as varchar, this is because of the need to store the extended character codes for other languages
Please provide your feedback for the post, if you find this post useful. Also Post your query or scenario, i will be happy to help.