Article ID: 116332 - Last Review: March 11, 2000 - Revision: 1.0 PRB: Floats May Be Rounded Up Using ODBC SQL Server DriverThis article was previously published under Q116332 SYMPTOMS
Using SQL Server ODBC driver and SQL Server and if ODBC prepared execution
is used, certain floating point values may be incorrectly converted. NOTE:
Microsoft Access and Microsoft Visual Basic commonly use the ODBC prepared
execution.
For example, consider a SQL Server table with a float column. When an ODBC application successfully executes an insert into that table with the float column value = 2.9 using prepared execution. However, when a query to get the rows with the float values equal to 2.9 is executed, no rows are returned from SQL Server. The following query is an example: In case of Microsoft Access and Visual Basic, the behavior is exhibited by doing the insert into either an attached table or by creating the dynaset, followed by running the query to retrieve the records where float column equals the value inserted. For example, CAUSE
The difference in behavior is because in the case of prepared execution,
the ODBC driver is doing the conversion to float; whereas in the case of
non-prepared execution and DB-Lib client tools, SQL Server is doing the
conversion.
WORKAROUND
To workaround this problem, you can do an explicit convert on the SQL
Server using a statement similar to the following:
Please note that this problem does not occur using pass-through mechanism since in that case, the conversion is done by SQL Server. | Article Translations
|

Back to the top
