DB-Library for C Data Types

DB-Library defines data type tokens for Microsoft® SQL Server™ data. These data type constants begin with “SQL” (for example, SQLINT4, SQLMONEY, or SQLCHAR). DB-Library also provides type definitions for use in program variable declarations. These type definitions begin with the prefix “DB” (for example, DBINT, DBCHAR, or DBMONEY). By using them, you ensure that your program variables will be compatible with SQL Server data types. For more information about a list of SQL Server data types and the DB-Library program variable types, see Using DB-Library for C Data Types.

The dbconvert function provides a way to convert data from one SQL Server data type to another. It supports conversion between most data types. Because SQL Server data types correspond directly to the DB-Library data types, you can use dbconvert widely within your application.

The functions that bind SQL Server result columns to program variables  dbbind and dbaltbind also provide type conversion.

When the operators SUM and AVG are applied to any column with a small data type (such as smalldatetime, real, smallmoney, smallint, or tinyint), the server returns results in the larger data type. For example, suppose that the table sales has a smallmoney column named price and the following query is executed on this table:

SELECT price FROM sales

  

COMPUTE SUM(price), AVG(price), MIN(price), MAX(price)

  

The returned values price, MIN(price), and MAX(price) are of the data type smallmoney; AVG(price), and SUM(price) are of the data type money.

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.