This article was previously published under Q274353
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 58065 (SQLBUG_70)
When you use the Microsoft SQL Server 7.0 Query Analyzer client tool with a smallint data type and a COMPUTE clause, unexpected results may be returned for the computed summary result. This behavior occurs only with negative numbers between -10000 and -32768.
To work around this problem, use either of the following:
Use one of the following client tools instead:
OSQL or ISQL command line utilities to run the query.
Use Microsoft SQL Server 6.5 ISQL_W or Microsoft SQL Server 2000 Query Analyzer to run the query.
Use the INT data type
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
274799 INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.
Steps to Reproduce Behavior
Run this code:
if object_id('t1') is not nullDROP TABLE t1goCREATE TABLE t1 ( my_int smallint)goINSERT INTO t1 VALUES(-10000)INSERT INTO t1 VALUES (10000)goSELECT my_int FROM t1 COMPUTE MIN(my_int)go