BUG: Arithmetic Overflow When Convert Real ValueLast reviewed: May 5, 1997Article ID: Q104801 |
The information in this article applies to:
SYMPTOMSUsing the CONVERT command to convert a valid real value from a column which allows nulls to a varchar or char large enough to hold the value causes arithmetic overflow or returns of zero. For example, the following script :
create table t1 (col1 float NULL) go insert t1 values (4.5) go select convert( varchar(10), col1) from t1 goWould generate the following error message:
Msg 232, Level 16, State 2: Arithmetic overflow error for type varchar, value = 0.000000 Arithmetic overflow occurred.On SQL Server version 4.2aK10 running with OS/2, the CONVERT command always returns the value zero, but no error messages. The same would occur when converting to a char type. NOTE: This is not a problem when the column does not allow nulls.
CAUSESQL Server incorrectly handles the conversion of a real column which allows nulls to varchar or char.
WORKAROUNDConvert the real value to float or real before converting to varchar or char datatypes. For the above example, use the following query to generate the correct result:
select convert( varchar(10), convert(float, col1)) from t1 STATUSMicrosoft has confirmed this to be a problem in SQL Server version 4.2 for OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
|
Additional query words:
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |