If I have an mssql varchar[1024] that is always empty in a table, how much actual bytes will be wasted in the db file on disk per row?
Please let me know the size for both:
- NULLs allowed storing ”
- NULLs not allowed storing ”
- NULLs allowed storing NULL
Since the max varchar size is > 2^1 and < 2^3 I would assume 2 bytes for the length. But perhaps there is some more overhead, for example if there is a reference that points to the actual data.
I believe that a varchar uses only the minimum storage required to hold the string. MSDN and books online seem to confirm this. However, the sum of stored data (including other fields) cannot exceed a certain length (which I think is 8K). I don’t think you’ve got this problem, as I think it is flagged at creation time.
more details are here: http://doc.ddart.net/mssql/sql70/ca-co_3.htm