sql_variant data type is designed to allow a single variable, column, or parameter to store values in different data types. : SQL_VARIANT « Data Types « SQL Server / T-SQL Tutorial






Internally, variant objects record two values:
The actual value
The metadata describing the variant: base data type, maximum size, scale, precision, and collation

13> Create table Lookup(
14>    LookupGroupId tinyint,
15>    LookupId smallint,
16>    LookupValue sql_variant)
17> Go
1>
2>
3> Insert Lookup (LookupGroupId, LookupId, LookupValue)
4>      Values (2, 34, 'VAR')
5> Insert Lookup (LookupGroupId, LookupId, LookupValue)
6>      Values (3, 22, 2000)
7> Insert Lookup (LookupGroupId, LookupId, LookupValue)
8>      Values (4, 16, '1/12/2000')
9> Insert Lookup (LookupGroupId, LookupId, LookupValue)
10>      Values (4, 11, $50000)
11> GO

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)
1>
2> drop table Lookup;
3> GO
1>
2>
3>








5.22.SQL_VARIANT
5.22.1.sql_variant data type is designed to allow a single variable, column, or parameter to store values in different data types.
5.22.2.The creation of the table, with a column of the SQL_VARIANT type.
5.22.3.Insert different type of values into a sql_variant column
5.22.4.sql_variant type column
5.22.5.Select case and cast SQL_VARIANT
5.22.6.Comparing SQL_VARIANTs