Interview Questions
1) What is the Advantage of Char over Varchar ..?
Char -- a) Fixed size or length.
b) Static allocation of memory.
If you say Char(5) 5 bytes of space is allocated for char. Even if you use only 2 bytes remaining 3 bytes will still be there.
c) It Stores non unicode characters.
Varchar--
a) Variable size or length
b) Dynamic memory allocation.
If you say Varchar(5) and store only 2 bytes. The remaining 3 bytes will not be there.
c) It stores non unicode characters.
As Char is static memory allocation, it is 50% faster than Varchar.
2) What is the difference between NChar and NVarchar ?
NChar -- Same as Char, except that it stores unicode(double byte) characters.
By unicode we mean that the characters of different languages like german,chineese which takes 2 bytes.
There are some languages which takes 2bytes to store a character like German.
NVarchar -- Same as Varchar , except that it stores unicode(double byte) characters.