Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 data types related question
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 02/17/2013 :  00:44:26  Show Profile  Reply with Quote
let say this small table of Persons

1------Nevlon------David------H-jol jsj
2------Martin------D'souza----1/78 hdjj
3------Bart--------Cruz-------45 4555

My question: when we declare a datatype for the columnname firstname as vchar(100) ....does this mean that (100) is for a an indivual field in the Firstname column(like its 100 for field Nevlon, then 100 for martin, so on) or just the whole column (like combination of 1, 2, 3 and so on)

second question
what does variable character mean(please explain in layman terms)? why is it different from char data type?

Thanks for reading my question.

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/17/2013 :  01:45:36  Show Profile  Reply with Quote
varchar(100) means each value in column can have maximum of 100 characters (ie Nevlon,Martin etc each of those values can be 100 char max)
varchar mean variable character. It implies that based of number of characters actually present, it will assume only the required space. ie for Nevlon it will take only size corresponding to 6 characters. In contrast, char datatypes takes the full size regardless of actual size of data. ie for Nevlon also it takes full 100 character size and fills the rest with spaces. You can check that using below code.

SELECT CAST('Nevlon' AS varchar(100)) AS varcharval,CAST('Nevlon' AS char(100)) AS charval

The varchar field will only return size corresponding to 6 characters present whereas char will return size corresponding to entire 100 characters

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000