This is one of the important article because NULL value is occupying space in the SQL Server.
NULL is an Unknown value and it occupies space in SQL Server based on the column data type.
Fixed length Character:
CHAR(3): NULL value occupies 3 bytes.
Integer data type:
int: NULL value occupies 4 bytes.
Variable length data type:
VARCHAR(10): NULL value occupies 2 bytes.
The Sparse Columns:
It is just like any other column, but it reduces the space requirements for the NULL values.
As per the Microsoft’s official document, it saves the space at least up to 20% to 40%.
We can specify SPARSE keyword in the column definition for making SPARSE Column.
Create a table with SPARSE column:
CREATE TABLE tbl_SPARSEColumns
ID INTEGER NOT NULL
,Name VARCHAR(50) SPARSE NULL
,Address VARCHAR(255) SPARSE NULL
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.