initial length byte in variable string types

  • That might be an old habit of people who worked with earlier versions of SQL Server. The 255 was the maximum supported by the server.

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • Jacek0 is right. There is no performance advantage to a given maximum length for varchar columns. In fact, for very short columns the overhead of using varchar might outweigh the "unused" bytes of a char column. Using varchar(x), where x is some integer, essentially amounts to a maximum length constraint. This can be useful but, as stated before, the maximum length doesn't buy you any performance gains.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Hi

    The 2^n-1 logic comes from old systems because the last character was a 0-character which terminated the string. New systems usually do not use this termination and are optimized to handle any size of strings.

    Greets

    Flo

  • Some systems used first byte to hold number of characters of string with a maximum of 255 bytes.


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply