The subject of NULL values size has been discussed in many topics like this one in SO.
I could understand that if the row is of fixed size, int
or varchar(x)
NULL valeus take space (zeros if the attribute is int
or spaces if the attribute is varchar(x)
) + 1 byte for NULL bitmap.
I created a table with two attributes:
CREATE TABLE Person (id int NULL, name VARCHAR(50) NULL)
.
And used the script here to get for each row the size in B:
I could read from the table these facts:
- The first three rows: 1 byte per each letter + 1 byte for NULL bitmap.
- The 4th row: 2 NULL bitmaps.
- The last two rows: 4 bytes of int + 1 byte for NULL bitmap.
Why the int/varchar(50) NULL values above didn't take all the declared size?
I'm using SQL Server Management Studio 2014. Did norms change?