Microsoft KB Archive/104801

{|
 * width="100%"|

The information in this article applies to:
 * Microsoft SQL Server versions 4.2 and 4.2a for OS/2

BUG# OS/2: 1763 (4.2)

SYMPTOMS
Using 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  go Would 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.

CAUSE
SQL Server incorrectly handles the conversion of a real column which allows nulls to varchar or char.

WORKAROUND
Convert 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

STATUS
Microsoft 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.
 * }

-

Last reviewed: May 5, 1997

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.