FIX: Incorrect Results Returned When Query Compares Large Precision and Scale Decimal Value with Integer (308736)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q308736
BUG #: 354044 (SHILOH_BUGS)

SYMPTOMS

A query may return incorrect results when it compares an integer value with a decimal value that has a precision and scale greater than 28.

For example, the following query demonstrates the problem:
USE pubs
GO

CREATE TABLE t1 (c INT)
GO

INSERT INTO t1 VALUES (10)
GO

-- The decimal number has 30 9s
SELECT * FROM t1 WHERE c = CONVERT( DECIMAL( 30, 29), 9.99999999999999999999999999999 )
GO
				
The preceding SELECT query should not return a value. However, the query returns a value of 10.

CAUSE

A decimal value with a precision and scale greater than 28 is incorrectly rounded when compared to an integer.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

STATUS

Microsoft has confirmed that this is a problem in Microsoft SQL Server 2000. This problem was first corrected in Microsoft SQL Server 2000 Service Pack 2.

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbbug kbfix KB308736