Varchar columns

runrig on 2004-04-14T22:10:42

I just noticed that in our SqlServer databases we have alot of 'varchar(1,0)' columns. I know that if you have a long character column that tends to be short or blank, you can save space by making it a varchar instead of a char, but it can't be worth making a varchar for a one character field, can it? (And in most cases, the fields I'm looking at will always be 'Y' or 'N').

Update: In my homegrown DBI sql query tool the '0' above is from the 'SCALE' for numeric columns, which I display if the value is defined (whether or not the column is numeric). I'm not sure if this is also the reserve length for varchar columns, or if SqlServer happens to define it as zero.


No

malte on 2004-04-15T15:32:25

VARCHAR with length 1 will cost you an extra byte per column and row, plus unless your DB's optimizer is very smart it might make some operations slower.