Since the storage requirements for a Varchar field are based on the actual length of the string entered, what would be the downside of specifying every Varchar field as the max possible: Varchar (65535)? Well, aside from 1 extra byte for max fields > 255 characters?
[Storage Reqts for strings of length L: L + 1 bytes if column values require 0 – 255 bytes, L + 2 bytes if values may require more than 255 bytes]
Thank you!
I think
varcharcolumn lengths are not only about storage. They’re about data semantics as well.I.E. specifying a
namecolumn asvarchar(100)means that names stored on your system must not be longer than 100 characters.On the storage side of things, they should be the same. Although, row size estimations would be more accurate with a specific length on
varcharcolumns that without them (without needing a statistics gathering system keeping data distributions onvarcharsizes).