• diamondgm (10/16/2009)


    Firstly, we assume that the average is the result of an even spread (that the average length is in fact 8.5 - we only need an average of 8 for storage to be a moot point in char vs varchar).

    Secondly, within SQL Server, the efficiency may be best to use char in that instance, but take in to account the code operations of trimming and I think it becomes debatable.

    I agree with you on a purist level, but practically, I would go with varchar still simply for the programmers' ease.

    Nice question 🙂

    I agree with the author of the question when it comes to storage size (and IO performance), but there are more things to think of than storage, like you the trailing spaces that has to be stripped.

    I got the question correct because I thought it had a catch, but personally, I would only use char in rare cases unless all the data for the column are equal.

    /Håkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform