Powered By Blogger

Tuesday, November 3, 2009

varchar and nvarchar in SQL Server

VARCHAR
  • VARCHAR is an abbreviation for variable-length character string.
  • VARCHAR is stored as regular 8-bit data.
  • Varchar (MAX) can hold max of 2,147,483,648 characters
NVARCHAR
  • The "N" in NVARCHAR means uNicode.
  • NVARCHAR strings are stored in the database as UTF-16 — 16 bits or two bytes per character
  • NVARCHARs use two bytes for each character, that means a given NVARCHAR can only hold 4,000 characters (not bytes) maximum.
  • NVARCHAR (MAX) can hold 1,073,741,823 characters
  • The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters.

  • The difference is that nvarchar is used to store unicode data, which is used to store multilingual data in your database tables.

No comments:

Post a Comment