I've read that in SQL Server, fixed-width data types always occupy space whether a column value is NULL or not whereas variable-width data types do not if the column value is NULL. Is there a variable-width equivalent to int, float, datetime, etc.?
Asked
Active
Viewed 1,301 times
0
-
There was a `vardecimal` in SQL Server 2008 - but that's been deprecated again in favour of row/page compression – marc_s Oct 17 '12 at 04:54
2 Answers
1
Q: Are there variable types that don't consume a fixed amount of space?
A: Sure. nvarchar, ntext, image and Document XML come immediately to mind.
Q: Is there anything besides fixed width for types like int, number or datetime?
A: Nope :)

paulsm4
- 114,292
- 17
- 138
- 190
1
You are correct that the datatypes that start with "VAR" do not take up space on the data page when they are valued NULL. The datatypes for which a VAR version is available are only the character and binary datatypes. All the other ones like INT and DATETIME always take a fixed amount of space independent of their value. See Space used by nulls in database

Community
- 1
- 1

Sebastian Meine
- 11,260
- 29
- 41
-
There are some exception, e.g. compression, sparse columns and consecutive bit columns. – Aaron Bertrand Oct 17 '12 at 00:41