>I was told that char is better than varchar. Is this right?

>I am going to have fields that are set to be either 25  50 100 or 150
>characters long. Is there a reason any of these fields should be char or
>varchar? I have always used varchar but I would like to know what is best.

As in most things, "Better" is a relative judgment. The primary difference
is that CHAR fields are right padded with spaces which can make them
difficult to work with if your data is not all of the same size (say an SKU
that is always a certain number of characters in length).

VARCHAR fields store variable length character data without padding the data
with white space. In my experience, the data stored in VARCHAR fields is
easier to work with because I find I'm using the TRIM() function often with
CHAR fields to eliminate the excess spaces.

One other key difference in terms of functionality is that the CHAR data
type does not allow null values. If you create a field in a table as CHAR
with nulls allowed, SQL Server will just create that field as VARCHAR and
you'll never know the difference except if you expect the data to be padded.

Since the CHAR data type has less overhead associated with it, it is
slightly faster than the VARCHAR data type. However, this is very minimal
performance gain, one that is completely negated if you find yourself using
the TRIM() function on the ColdFusion side.

>Feel free to respond directly to me since it is OT ;-)

Actually, I think this is pretty right on. :)

Benjamin S. Rogers
Web Developer, c4.net
voice: (508) 240-0051
fax: (508) 240-0057

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to