Data Type Mapping for Embedded SQL

Embedded SQL for C (ESQL/C) maps C data types to Microsoft® SQL Server™ data types, and vice versa. No Unicode data types are supported in ESQL/C (for example, the data types nvarchar, nchar, and ntext are not supported). Conversions are supported for all non-Unicode data types except datetime or smalldatetime, money or smallmoney, and, in some instances, decimal or numeric. Data types that can be converted to datetime or smalldatetime, money or smallmoney, and decimal or numeric are indicated by T.



C data type
Assigned
SQL Server
data type

datetime or
smalldatetime

money or
smallmoney

decimal or numeric
short smallint F F F
int smallint F F F
long int F F F
float real F F F
double float F F F
char varchar[x] (1) T T T
void *p binary (2) T T T
char byte tinyint F F F
1    For more information, see Mapping Character Data Types.

2    For more information, see Pointers as Host Variables.


The above table is valid for SQL Server version 6.5. In SQL Server 7.0, mapping from one type to another is done by the database server. So all the above conversions are true in SQL Server 7.0.

Output data is truncated if the receiving data type is too short. This causes an exception (warning), and the SQLCODE field of the SQLCA data structure is set to +1. Input data can be truncated if the receiving SQL Server column is too short. However, in this case, no exception is generated.

Because text data types are not allowed in stored procedures, you cannot use C fields that are more than 255 bytes long in static SQL statements compiled into access plans.

  


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