Just Code‎ > ‎

TSQL - Storage Overhead of the SQL_Variant Data type

posted Nov 28, 2011, 7:25 AM by Peter Henell   [ updated Jan 25, 2012, 5:18 AM ]
The SQL_VARIANT datatype is interesting since it can hold almost any datatype, but what is the overhead of that flexibility?

The overhead for each of the data types that SQL_VARIANT can hold listed below. This means that for each record there will be this much overhead for storing the different kind of data types inside a SQL_VARIANT column.
--For numeric and decimal: 1 byte for the precision and 1 byte for the scale
--for strings: 2 bytes for the length and 4 byts for the collation
--for binary and varbinary: 2 bytes for the length
--for all other types: no extra bytes!
Comments