Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Char and Varchar

Status
Not open for further replies.

SpiderBear6

Programmer
Sep 17, 2003
422
AU
Need expert advice...

How few characters should a varchar go? For example, if I had a field which would had a maximum of 12 characters in it.. would it be better for performance to make it a char(12) or a varchar(12)?

:)

--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 
I always opt for VarChar if the length of the data can be less than the maximum. There's less data to shift around and you dont have the aggravation of remembering to remove the trailing spaces.
 
That's what I thought but a friend of mine said that is was inefficient to use varchars for smaller lengths like 10.

--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 
Takes up a bit more storage space for a filled field and is a bit more effort to retrieve but you are better off spending the time designing correctly rather than thinking about things like this.
Even with small fields can end up slower.
Any gains made would be lost by having to trim the field.

If a field is fixed length make it char if not varchar.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
"If a field is fixed length make it char if not varchar. " Even if the length can vary by only 1 character?

Umm.. I am trying to design correctly that's why I am thinking about this..:)

--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top