FIX: Negative 0 (zero) Causes ODBC SQL Server Driver Error

Article translations Article translations
Article ID: 235281 - View products that this article applies to.
This article was previously published under Q235281
Expand all | Collapse all

SYMPTOMS

If a SQL Server query returns a negative zero, and the client application binds the results as a SQL_C_DOUBLE, the following error is reported to the client:
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

CAUSE

SQL Server is returning a negative zero, and the SQL Server driver is reporting this as an error. To reproduce the error run the following query:
SELECT 0.0 * -1
				
When you fetch the resulting column from this query you receive the error. In a more complex scenario the following query also causes the error:
SELECT col1 * -1 FROM mytable
				

WORKAROUND

Either bind the column as a SQL_C_CHAR or SQL_C_LONG to avoid the error. You can also check that the resulting data does not contain a negative zero.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
254561 INF: How to Obtain Service Pack 2 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.

Properties

Article ID: 235281 - Last Review: March 14, 2006 - Revision: 4.1
APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft ODBC Driver for Microsoft SQL Server 3.7
Keywords: 
kbbug kbfix kbsqlserv700sp2fix KB235281

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com