Tuesday 25 September 2012

Difference between char,varchar and nvarchar in sql server

Hi friends,In this article i have explained what is the difference between char , varchar and  nvarchar in sql server.

char Data Type:

char datatype is used to store fixed length of character.For example if we declared char(50) it will allocate memory for character 50. once we declare char(50) and insert only 10 character then it only use 10 character of memory and other 40 character of memory will be wasted.

varchar datatype:

Varchar means variable character .It will allocate the memory based on number of character inserted. Suppose that if we have declare varchar(50) it allocate 0 memory of character  at the time of declaration.
Once we declare varchar(50) and insert only 10 values the it only use 10 character of memory.

nvarchar datatype:

nvarchar datatype same as varchar datatype but only difference nvarchar is used to store unicode characters and  it allows to store multiple lagauges in database.
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.