NULL values in sql-server

Do recordfields containing NULL-values take up storage space? (SQL-server 7)
LVL 1
pietjepukAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
The nullability of columns is referred to in the syscolumns table, with the exact definition of every column (type, size...)
Then for every row, the values are stored one after the other (fixed sized columns first), with some bytes of informations (number of columns, size of row...) This bytes include the nullbit-mask (taking 0 to n bytes).
So the answer is, this nullbit mask refers to the actual value of NULLS
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Yes, but only a few bytes (indicating that there is a NULL value)
0
 
pietjepukAuthor Commented:
In this specific situation a few bytes might very well add up to Gigabytes. Do you (or anyone) know exactly how many bytes?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
evertdCommented:
I think that is not documented but you can try to load 1000000 rows with NULL values and a table without the null values. Than look the size differences of the two tables.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
M$ reference:
For each variable-sized column (including nullable columns), byte usage is:
1 (or more) shared bytes per table  indicating columns are null or not (2 if more than 8 columns
0 byte per column that is null
0
 
ahoorCommented:
Also depends on the datatype.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ahoor: if value is null, datatype is not important: size is 0 bytes, the nullbit mask will be defined whatsoever and take 1 or more bytes (depending on the number of nullable columns in the table)
0
 
pietjepukAuthor Commented:
Adjusted points from 50 to 100
0
 
pietjepukAuthor Commented:
evertd, thanks for the suggestion but it doesn't answer my question(s).

angelIII,
So this nullbit mask uses bits (eight columns make up one byte). But does it refer to the nullability of columns, or to actual storage of null values?
0
 
pietjepukAuthor Commented:
OK, (I think) I get it. Through this nullbit masking up to 8 columns that are NULL can be stored into 1 byte (per row), right?

Thanks again.

Pietjepuk.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.