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

Home
SQL Server / T-SQL Tutorial
1.Query
2.Insert Delete Update
3.Table
4.Table Join
5.Data Types
6.Set Operations
7.Constraints
8.Subquery
9.Aggregate Functions
10.Date Functions
11.Math Functions
12.String Functions
13.Data Convert Functions
14.Analytical Functions
15.Sequence Indentity
16.View
17.Index
18.Cursor
19.Database
20.Transact SQL
21.Procedure Function
22.Trigger
23.Transaction
24.XML
25.System Functions
26.System Settings
27.System Tables Views
28.User Role
29.CLR
SQL Server / T-SQL Tutorial » Data Types » 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.
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 (234'VAR')
5> Insert Lookup (LookupGroupId, LookupId, LookupValue)
6>      Values (3222000)
7> Insert Lookup (LookupGroupId, LookupId, LookupValue)
8>      Values (416'1/12/2000')
9> Insert Lookup (LookupGroupId, LookupId, LookupValue)
10>      Values (411, $50000)
11> GO

(rows affected)

(rows affected)

(rows affected)

(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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.