difference between char, varchar, nvarchar?

Posted by Rajendra.prasad under Sql Server on 5/12/2011 | Points: 10 | Views : 23298 | Status : [Member] | Replies : 5
Hi,
difference between char, varchar, nvarchar?

Regards,
Rajendra




Responses

Posted by: Sandilian on: 5/12/2011 [Member] Starter | Points: 25

Up
0
Down
char - stores character data with fixed length
example: char(10) 10 character memory is allocated on the sql server memory location. suppose if your are not
utilizing 10 character memory means memory will be wasted.
varchar: Variable-length, non-Unicode character data. The database collation determines which code page the data is stored using. if your are not utilizing memory means memory will be collected.
nvarchar: Variable-length Unicode character data. Dependent on the database collation for comparisons. we can store international languages like Chinese, Japanese, hindi and Tamil languages.

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Msahoo on: 5/12/2011 [Member] Starter | Points: 25

Up
0
Down
char : - it stores fixed length of character. if you declare char(50) then it allocates memory for 50 characters. if you store 10 character word then it store it in 10 characters memory location and other 40 character's memory location will be wasted.

varchar : - varchar means variable characters. it allocates memory as per data stored into this. If you specify varchar(50) at the time of declaration then it allocates 0 memory location at the starting if you specify, it can be null. When you store 10 characters word it will allocate memory for 10 characters and store into that. So there will be no memory loss. It stores only non-unicode characters.

nvarchar : - nvarchar means unicode variable characters. it allocates memory as same as varchar. But It stores unicode characters.

Thank You.

Regards,
Manoranjan Sahoo
http://www.dotnetsquare.com

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 5/13/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,
Also refer the below link too....
http://www.teratrax.com/sql_guide/data_types/sql_server_data_types.html
Thanks,

Nitha Deepak

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pravesh Singh on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Rajendra!

You can get the help from the following link. I hope it very helpful for you.

http://www.mindstick.com/Blog/479/Difference%20between%20char%20var

Thanks & Regard!
Pravesh Singh

Pravesh Singh

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 6/7/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

refer this link.
http://stackoverflow.com/questions/176514/what-is-the-difference-between-char-nchar-varchar-and-nvarchar-in-sql-server,
http://exacthelp.blogspot.in/2012/01/difference-between-varchar-and-nvarchar.html,
http://www.aspdotnet-suresh.com/2012/07/difference-between-char-varchar-and.html

Thanks,
Bagesh Kumar Singh

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response