SSVARIANT Structure

 

System_CAPS_ICON_warning.jpg Warning

SQL Server Native Client (SNAC) is not supported beyond SQL Server 2012. Avoid using SNAC in new development work, and plan to modify applications that currently use it. The Microsoft ODBC Driver for SQL Server provides native connectivity from Windows to Microsoft SQL Server and Microsoft Azure SQL Database.

The SSVARIANT structure, which is defined in sqlncli.h, corresponds to a DBTYPE_SQLVARIANT value in the SQL Server 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 SQL Server 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:

MemberOLE DB type indicatorOLE DB C data typevt valueComments
vtSSVARTYPESpecifies the type of value contained in the SSVARIANT struct.
bTinyIntValDBTYPE_UI1BYTEVT_SS_UI1Supports the tinyintSQL Server data type.
sShortIntValDBTYPE_I2SHORTVT_SS_I2Supports the smallintSQL Server data type.
lIntValDBTYPE_I4LONGVT_SS_I4Supports the intSQL Server data type.
llBigIntValDBTYPE_I8LARGE_INTEGERVT_SS_I8Supports the bigintSQL Server data type.
fltRealValDBTYPE_R4floatVT_SS_R4Supports the realSQL Server data type.
dblFloatValDBTYPE_R8doubleVT_SS_R8Supports the floatSQL Server data type.
cyMoneyValDBTYPE_CYLARGE_INTEGERVT_SS_MONEY VT_SS_SMALLMONEYSupports the money and smallmoneySQL Server data types.
fBitValDBTYPE_BOOLVARIANT_BOOLVT_SS_BITSupports the bitSQL Server data type.
rgbGuidValDBTYPE_GUIDGUIDVT_SS_GUIDSupports the uniqueidentifierSQL Server data type.
numNumericValDBTYPE_NUMERICDB_NUMERICVT_SS_NUMERICSupports the numericSQL Server data type.
dDateValDBTYPE_DATEDBDATEVT_SS_DATESupports the dateSQL Server data type.
tsDateTimeValDBTYPE_DBTIMESTAMPDBTIMESTAMPVT_SS_SMALLDATETIME VT_SS_DATETIME VT_SS_DATETIME2Supports the smalldatetime, datetime, and datetime2SQL Server data types.
Time2ValDBTYPE_DBTIME2DBTIME2VT_SS_TIME2Supports the timeSQL Server data type.

Includes the following members:

 tTime2Val (DBTIME2)

 bScale (BYTE) Specifies the scale for tTime2Val value.
DateTimeValDBTYPE_DBTIMESTAMPDBTIMESTAMPVT_SS_DATETIME2Supports the datetime2SQL Server data type.

Includes the following members:

 tsDataTimeVal (DBTIMESTAMP)

 bScale (BYTE) Specifies the scale for tsDataTimeVal value.
DateTimeOffsetValDBTYPE_DBTIMESTAMPOFSETDBTIMESTAMPOFFSETVT_SS_DATETIMEOFFSETSupports the datetimeoffsetSQL Server data type.

Includes the following members:

 tsoDateTimeOffsetVal (DBTIMESTAMPOFFSET)

 bScale (BYTE) Specifies the scale for tsoDateTimeOffsetVal value.
NCharValNo corresponding OLE DB type indicator.struct _NCharValVT_SS_WVARSTRING,

 VT_SS_WSTRING
Supports the nchar and nvarcharSQL Server data types.

Includes the following members:

 sActualLength (SHORT) Specifies the actual length for for the string to which pwchNCharVal points. Does not include terminating zero.

 sMaxLength (SHORT) Specifies the maximum length for for the string to which pwchNCharVal points.

 pwchNCharVal (WCHAR *) Pointer to the string.

Unused members: rgbReserved, dwReserved, and pwchReserved.
CharValNo corresponding OLE DB type indicator.struct _CharValVT_SS_STRING,

 VT_SS_VARSTRING
Supports the char and varcharSQL Server 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.
BinaryValNo corresponding OLE DB type indicator.struct _BinaryValVT_SS_VARBINARY,

 VT_SS_BINARY
Supports the binary and varbinarySQL Server 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.
UnknownTypeUNUSEDUNUSEDUNUSEDUNUSED
BLOBTypeUNUSEDUNUSEDUNUSEDUNUSED

Data Types (OLE DB)

Community Additions

ADD
Show: