|
Home > Archive > MS SQL Server New Users > June 2005 > Varchar
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| HenryC 2005-06-15, 11:24 am |
| If a given text field is always 3 characters or less, is there a reason why
varchar(3) is better/more efficient etc., than varchar(4). Or does it really
make any difference? I was told when designing the table it really doesn't
matter. Is this true? If varchar(3) is the same as varchar(10), why
wouldn't there be just a varchar (without the lengty constraint)? What are
the advantages and disadvantages for specfying the "correct" length?
Thanks from a newbie
| |
| Adam Machanic 2005-06-15, 1:24 pm |
| For larger values, it can affect performance -- the query optimizer uses the
specified size as one of the factors in determining an optimal query plan.
But really, the more important issue is one of constraining values. If you
know that the maximum length should be 3, then a maximum length of 4 is
invalid -- by setting the length to 3, that's guaranteed for you.
--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"HenryC" <henry@tste.com> wrote in message
news:eq$MaJccFHA.2424@TK2MSFTNGP09.phx.gbl...
> If a given text field is always 3 characters or less, is there a reason
why
> varchar(3) is better/more efficient etc., than varchar(4). Or does it
really
> make any difference? I was told when designing the table it really
doesn't
> matter. Is this true? If varchar(3) is the same as varchar(10), why
> wouldn't there be just a varchar (without the lengty constraint)? What
are
> the advantages and disadvantages for specfying the "correct" length?
>
> Thanks from a newbie
>
>
|
|
|
|
|