As a general rule, consider the implications of using SQLBindCol to cause data conversion. Binding conversions are client processes, so, for example, retrieving a floating-point value bound to a character column causes the driver to perform the float-to-character conversion locally when a row is fetched. The Transact-SQL CONVERT function can be used to place the cost of data conversion on the server.
An instance of SQL Server can return multiple sets of result rows on a single statement execution. Each result set must be bound separately. For more information about binding for multiple result sets, see SQLMoreResults.
The developer can bind columns to SQL Server-specific C data types using the TargetType value SQL_C_BINARY. Columns bound to SQL Server-specific types are not portable. The defined SQL Server-specific ODBC C data types match the type definitions for DB-Library, and DB-Library developers porting applications may want to take advantage of this feature.
Reporting data truncation is an expensive process for the SQL Native Client ODBC driver. You can avoid truncation by ensuring that all bound data buffers are wide enough to return data. For character data, the width should include space for a string terminator when the default driver behavior for string termination is used. For example, binding a SQL Server char(5) column to an array of five characters results in truncation for every value fetched. Binding the same column to an array of six characters avoids the truncation by providing a character element in which to store the null terminator. SQLGetData can be used to efficiently retrieve long character and binary data without truncation.
For large value data types, if the user supplied buffer isn’t large enough to hold the entire value of the column, SQL_SUCCESS_WITH_INFO is returned and the “string data; right truncation” warning is issued. The StrLen_or_IndPtr argument will contain the number of chars/bytes stored in the buffer.