Data Type Usage Considerations

ADO and SQL Server

ADO and SQL Server

Data Type Usage Considerations

Microsoft® SQL Server™ 2000 includes the following data types that cannot be used with SQL Server version 7.0 or earlier:

  • bigint
  • sql_variant
Using the bigint Data Type

The bigint data type is an integer containing values from -2^63 (-9,223,372,036,854,775,807) through 2^63-1 (9,223,372,036,854,775,807). The storage size is 8 bytes.

The ADO enumerated constant, DataTypeEnum, specifies the data type of an ADO field, parameter, or property. The DataTypeEnum value, adBigInt, has a value of 20, and indicates an 8-byte signed integer, which maps to the SQL Server 2000 bigint data type and the OLE DB DBTYPE_I8 data type.

Using the sql_variant Data Type

The sql_variant data type can contain data of any of the SQL Server 2000 data types except those for large objects (text, ntext, and image data types), and the timestamp data type. For example, a sql_variant column can contain smallint values for some rows, float values for other rows, and char/nchar values in the remainder.

Although there are some restrictions, the sql_variant data type is similar to the variant data type in Microsoft Visual Basic® and DBTYPE_VARIANT in OLE DB. The ADO DataTypeEnum value, adVariant, has a value of 12, and maps to the OLE DB DBTYPE_VARIANT data type. However, ADO does not yet support this data type completely, and usage may cause unpredictable results.

For more information about support of the sql_variant data type by the Microsoft OLE DB Provider for SQL Server (SQLOLEDB), see Data Type Mapping in Rowsets and Parameters.