# BUG: Arithmetic Overflow When Convert Real Value

Last reviewed: May 5, 1997
Article ID: Q104801

###

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.

> Additional query words:
> Keywords : kbbug4.20 kbbug4.20a kbprg SSrvServer
> Version : 4.2 4.2a
> Platform : OS/2
> Issue type : kberrmsg
> THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.