TSQL - Storage Overhead of the SQL_Variant Data type

Post date: Nov 28, 2011 3:25:16 PM

The SQL_VARIANT datatype is interesting since it can hold almost any datatype, but what is the overhead of that flexibility?

BOL about SQL_VARIANT: http://msdn.microsoft.com/en-us/library/ms173829.aspx

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!