Click here to Skip to main content
15,899,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends
i am confused with varchar datatype. what i have known is varchar()take 1 byte for each character + extra 2 byte.why it takes extra 2 bytes. How many character will be stored in varchar(50) datatype.
Posted

extra 2 bytes reserved for null character '\0'
and varchar(50) will allow to store 50 characters.
'null character' bytes are managed by SQL internally.
 
Share this answer
 
The "var" bit means that the number of characters in the data is not fixed - it can be any number of bytes up to the maximum. The additional bytes are the count of the number of bytes currently used, generally.

So varchar(50) could hold 0 to 50 characters, and would take 52 bytes to store.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900