In this article I share some observations I’ve had regarding the datetime2 data type’s storage size in SQL Server. Perhaps I will clarify some points about the actual storage size used by this data type when stored in a database.
In particular, I look at the following:
- Microsoft’s documentation
- Data stored in a variable
- Length in bytes using
DATALENGTH() - Length in bytes using
DATALENGTH()after converting to varbinary
- Length in bytes using
- Data stored in a database
- Length in bytes using
COL_LENGTH() - Length in bytes using
DBCC PAGE()
- Length in bytes using
Some of those seem to contradict each other, and you will see two different storage size amounts for the same value, depending on where you look.