SQL Server - what is the difference between nchar and nvarchar(50)

Asked By aman on 18-Jul-11 02:55 AM
hi all,
how i could get the exact difference between the nchar and nvarchar(50)......show practically
thanks and regards
Aman Khan
Jitendra Faye replied to aman on 18-Jul-11 02:57 AM

we have two types of character data type:

1.fixed-length (nchar)
2.variable-length (nvarchar)

1.nchar(n) - nchar are national char and national character.

i)Fixed-length unicode character of n characters.
ii)value of n is from 1 through 4,000.
iii)Storage size is two times n bytes.

2.nvarchar(n) - nvarchar are national char varying and national character varying.

i)Variable-length Unicode character of n characters
ii)value from of n is 1 through 4,000.
iii)Storage size, in bytes, is two times the number of characters entered
iv)Entered data can be 0 characters in length.

Kalit Sikka replied to aman on 18-Jul-11 02:59 AM
nchar and char pretty much operate in exactly the same way as each other, as do nvarchar and varchar. The only difference between them is that nchar/nvarchar store Unicode characters (essential if you require the use of extended character sets) whilst varchar does not. Because Unicode characters require more storage, nchar/nvarchar fields take up twice as much space (so for example in earlier versions of SQL Server the maximum size of an nvarchar field is 4000).

  • char: fixed-length character data with a maximum length of 8000 characters.
  • nchar: fixed-length unicode data with a maximum length of 4000 characters.
  • Char = 8 bit length
  • NChar = 16 bit length
Ravi S replied to aman on 18-Jul-11 02:59 AM

  • nchar is fixed-length and can hold unicode characters. it uses two bytes storage per character.

NVARCHAR can store Unicode characters and takes 2 bytes per character.
Reena Jain replied to aman on 18-Jul-11 03:01 AM

nchar -> this is for unicode data type. This can store more than 256 characters [2 power 32 characters]. Memory storage might happen,

nvarchar-> this is also for unicode data type. This also can store more than 256 characters [2 power 32 characters]. Memory wastage is not there.


Nchar(50) will always occupy same space irrespective of the size of data.
Nvarchar(50) can store maximum 50 characters but the actual size depends on the data that is stored

Hope this will help you
Riley K replied to aman on 18-Jul-11 03:04 AM
VARCHAR is an abbreviation for variable-length character string. It is a string of text characters that can be as large as the page size for the database table holding the column in question. The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.

The N in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters.

The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols - in my case, English and Japanese.

Hope you got it now
msakt replied to aman on 18-Jul-11 03:21 AM
 nchar(50) space get 50,if use 2 char but space allocate 50........so 48 space waste
if use nvarchar(50),but use 2 char space allocate 2 only
nchar==compiletime memory allocation
nvarchar==run time memory allocation