| title | SSVARIANT structure (Native Client OLE DB provider) | |
|---|---|---|
| description | SSVARIANT Structure in SQL Server Native Client | |
| author | markingmyname | |
| ms.author | maghan | |
| ms.date | 03/16/2017 | |
| ms.service | sql | |
| ms.subservice | native-client | |
| ms.topic | reference | |
| f1_keywords |
|
|
| helpviewer_keywords |
|
[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]
The SSVARIANT structure, which is defined in sqlncli.h, corresponds to a DBTYPE_SQLVARIANT value in the [!INCLUDEssNoVersion] Native Client OLEDB provider.
SSVARIANT is a discriminating union. Depending on the value of the vt member, the consumer can determine which member to read. vt values correspond to [!INCLUDEssNoVersion] data types. Therefore, the SSVARIANT structure can hold any SQL Server type. For more information about the data structure for standard OLE DB types, see Type Indicators.
When DataTypeCompat==80, several SSVARIANT subtypes become strings. For example, the following vt values will appear in SSVARIANT as VT_SS_WVARSTRING:
-
VT_SS_DATETIMEOFFSET
-
VT_SS_DATETIME2
-
VT_SS_TIME2
-
VT_SS_DATE
When DateTypeCompat == 0, these types will appear in their native form.
For more information about SSPROP_INIT_DATATYPECOMPATIBILITY, see Using Connection String Keywords with SQL Server Native Client.
The sqlncli.h file contains variant access macros that simplify dereferencing the member types in the SSVARIANT structure. An example is V_SS_DATETIMEOFFSET, which you can use as follows:
memcpy(&V_SS_DATETIMEOFFSET(pssVar).tsoDateTimeOffsetVal, pDTO, cbNative);
V_SS_DATETIMEOFFSET(pssVar).bScale = bScale;
For the complete set of access macros for each member of the SSVARIANT structure, refer to the sqlncli.hi file.
The following table describes the members of the SSVARIANT structure:
| Member | OLE DB type indicator | OLE DB C data type | vt value | Comments |
|---|---|---|---|---|
| vt | SSVARTYPE | Specifies the type of value contained in the SSVARIANT struct. | ||
| bTinyIntVal | DBTYPE_UI1 | BYTE | VT_SS_UI1 | Supports the tinyint[!INCLUDEssNoVersion] data type. |
| sShortIntVal | DBTYPE_I2 | SHORT | VT_SS_I2 | Supports the smallint[!INCLUDEssNoVersion] data type. |
| lIntVal | DBTYPE_I4 | LONG | VT_SS_I4 | Supports the int[!INCLUDEssNoVersion] data type. |
| llBigIntVal | DBTYPE_I8 | LARGE_INTEGER | VT_SS_I8 | Supports the bigint[!INCLUDEssNoVersion] data type. |
| fltRealVal | DBTYPE_R4 | float | VT_SS_R4 | Supports the real[!INCLUDEssNoVersion] data type. |
| dblFloatVal | DBTYPE_R8 | double | VT_SS_R8 | Supports the float[!INCLUDEssNoVersion] data type. |
| cyMoneyVal | DBTYPE_CY | LARGE_INTEGER | VT_SS_MONEY VT_SS_SMALLMONEY | Supports the money and smallmoney[!INCLUDEssNoVersion] data types. |
| fBitVal | DBTYPE_BOOL | VARIANT_BOOL | VT_SS_BIT | Supports the bit[!INCLUDEssNoVersion] data type. |
| rgbGuidVal | DBTYPE_GUID | GUID | VT_SS_GUID | Supports the uniqueidentifier[!INCLUDEssNoVersion] data type. |
| numNumericVal | DBTYPE_NUMERIC | DB_NUMERIC | VT_SS_NUMERIC | Supports the numeric[!INCLUDEssNoVersion] data type. |
| dDateVal | DBTYPE_DATE | DBDATE | VT_SS_DATE | Supports the date[!INCLUDEssNoVersion] data type. |
| tsDateTimeVal | DBTYPE_DBTIMESTAMP | DBTIMESTAMP | VT_SS_SMALLDATETIME VT_SS_DATETIME VT_SS_DATETIME2 | Supports the smalldatetime, datetime, and datetime2[!INCLUDEssNoVersion] data types. |
| Time2Val | DBTYPE_DBTIME2 | DBTIME2 | VT_SS_TIME2 | Supports the time[!INCLUDEssNoVersion] data type. Includes the following members: tTime2Val (DBTIME2) bScale (BYTE) Specifies the scale for tTime2Val value. |
| DateTimeVal | DBTYPE_DBTIMESTAMP | DBTIMESTAMP | VT_SS_DATETIME2 | Supports the datetime2[!INCLUDEssNoVersion] data type. Includes the following members: tsDateTimeVal (DBTIMESTAMP) bScale (BYTE) Specifies the scale for tsDateTimeVal value. |
| DateTimeOffsetVal | DBTYPE_DBTIMESTAMPOFFSET | DBTIMESTAMPOFFSET | VT_SS_DATETIMEOFFSET | Supports the datetimeoffset[!INCLUDEssNoVersion] data type. Includes the following members: tsoDateTimeOffsetVal (DBTIMESTAMPOFFSET) bScale (BYTE) Specifies the scale for tsoDateTimeOffsetVal value. |
| NCharVal | No corresponding OLE DB type indicator. | struct _NCharVal | VT_SS_WVARSTRING, VT_SS_WSTRING |
Supports the nchar and nvarchar[!INCLUDEssNoVersion] data types. Includes the following members: sActualLength (SHORT) Specifies the actual length for the string to which pwchNCharVal points. Does not include terminating zero. sMaxLength (SHORT) Specifies the maximum length for the string to which pwchNCharVal points. pwchNCharVal (WCHAR *) Pointer to the string. Unused members: rgbReserved, dwReserved, and pwchReserved. |
| CharVal | No corresponding OLE DB type indicator. | struct _CharVal | VT_SS_STRING, VT_SS_VARSTRING |
Supports the char and varchar[!INCLUDEssNoVersion] data types. Includes the following members: sActualLength (SHORT) Specifies the actual length for the string to which pchCharVal points. Does not include terminating zero. sMaxLength (SHORT) Specifies the maximum length for the string to which pchCharVal points. pchCharVal (CHAR *) Pointer to the string. Unused members: rgbReserved, dwReserved, and pwchReserved. |
| BinaryVal | No corresponding OLE DB type indicator. | struct _BinaryVal | VT_SS_VARBINARY, VT_SS_BINARY |
Supports the binary and varbinary[!INCLUDEssNoVersion] data types. Includes the following members: sActualLength (SHORT) Specifies the actual length for the data to which prgbBinaryVal points. sMaxLength (SHORT) Specifies the maximum length for the data to which prgbBinaryVal points. prgbBinaryVal (BYTE *) Pointer to the binary data. Unused member: dwReserved. |
| UnknownType | UNUSED | UNUSED | UNUSED | UNUSED |
| BLOBType | UNUSED | UNUSED | UNUSED | UNUSED |