Datatype Usage

The SQL Server driver and SQL Server impose the following usage of data types.

Datatype Limitation
Date literals Date literals, when stored in an SQL_TIMESTAMP column (SQL Server datatypes of datetime or smalldatetime), have a time value of 12:00:00.000 a.m. (midnight).
money and smallmoney Only the integer parts of the money and the smallmoney datatypes are significant. If the decimal part of SQL money data is truncated during datatype conversion, the SQL Server driver returns a warning, not an error.
SQL_BINARY (nullable) When connected to SQL Server version 6.0 and earlier, if an SQL_BINARY column is nullable, the data that is stored in the data source is not padded with zeroes. When data from such a column is retrieved, the SQL Server driver pads it with zeroes on the right. However, data that is created in operations performed by SQL Server, such as concatenation, does not have such padding.
SQL_CHAR (truncation) When connected to SQL Server version 6.0 and earlier, and data is placed into a SQL_CHAR column, SQL Server truncates it on the right without warning if the data is too long to fit into the column.
SQL_CHAR (nullable) When connected to SQL Server version 6.0 and earlier, if a SQL_CHAR column is nullable, the data that is stored in the data source is not padded with blanks. When data from such a column is retrieved, the SQL Server driver pads it with blanks on the right. However, data that is created in operations performed by SQL Server, such as concatenation, does not have such padding.
SQL_LONGVAR BINARY, SQL_LONGVAR CHAR Updates of columns with SQL_LONGVARBINARY or SQL_LONGVARCHAR data types (using a WHERE clause) that affect multiple rows are fully supported when connected to SQL Server 6.x. When connected to SQL Server 4.2x, an S1000 error "Partial insert/update. The insert/update of a text or image column(s) did not succeed" is returned if the update affects more than one row.
String function parameters string_exp parameters to the string functions must be of data type SQL_CHAR or SQL_VARCHAR. SQL_LONG_VARCHAR data types are not supported in the string functions. The count parameter must be less than or equal to 255, because the SQL_CHAR and SQL_VARCHAR data types are limited to a maximum length of 255 characters.
Time literals Time literals, when stored in an SQL_TIMESTAMP column (SQL Server datatypes of datetime or smalldatetime), have a date value of January 1, 1900.
timestamp Only a NULL value can be manually inserted into a timestamp column. However, because timestamp columns are automatically updated by SQL Server, a NULL value is overwritten.
tinyint The SQL Server tinyint datatype is unsigned. A tinyint column is bound to a variable of data type SQL_C_UTINYINT by default.
User-defined data types When connected to SQL Server 4.2x, the SQL Server driver adds NULL to a column definition that does not explicitly declare a column's nullability. Therefore, the nullability that is stored in the definition of a user-defined datatype is ignored.

When connected to SQL Server 4.2x, columns with a user-defined datatype that has a base datatype of char or binary and for which no nullability is declared are created as datatype varchar or varbinary. SQLColAttributes, SQLColumns, and SQLDescribeCol return SQL_VARCHAR or SQL_VARBINARY as the data type for these columns. Data that is retrieved from these columns is not padded.

LONG data types SQL_LONGVARBINARY data must be passed to SQLPutData as raw binary data, not as binary data that is converted to character data. Also, data-at-execution parameters are restricted for both the SQL_LONGVARBINARY and the SQL_LONGVARCHAR data types.

For details, see the Data-at-Execution Parameter Limitations topic.