Re: Char or varchar for a primary key?




Because of some other considerations (the 'first' VARCHAR column will
cost an additional 5 bytes per row), when in doubt, I would choose CHAR
over VARCHAR. In your case, I would choose VARCHAR(10) if the average
length is 6 or smaller. Otherwise I would choose CHAR(10).


Usually the key is fully filled, so I think I'll try to change varchar to
char.

Davide.


.



Relevant Pages

  • Re: Char and Varchar
    ... If the maximum length is short (<= 10 characters), ... maximum length, I also use CHAR. ... I use VARCHAR if long and short ...
    (microsoft.public.sqlserver.server)
  • Re: Char and Varchar
    ... If the maximum length is short (<= 10 characters), ... maximum length, I also use CHAR. ... I use VARCHAR if long and short ...
    (microsoft.public.sqlserver.programming)
  • Re: char vs varchar and indexes
    ... all these while i've only used varchar for any string ... i heard from my ex-boss that char helps speed up searches. ... handling/comparing a char column versus a varchar column. ... The other consideration is fragmentation. ...
    (comp.databases.ms-sqlserver)
  • Re: Char and Varchar
    ... correcting a small error and adding an ... > maximum length, I also use CHAR. ... >>How would a primary clustered key behave if it was built on a VARCHAR ... > forwarding pointer is changed. ...
    (microsoft.public.sqlserver.server)
  • Re: Char and Varchar
    ... correcting a small error and adding an ... > maximum length, I also use CHAR. ... >>How would a primary clustered key behave if it was built on a VARCHAR ... > forwarding pointer is changed. ...
    (microsoft.public.sqlserver.programming)