Microsoft KB Archive/290817

= FIX: Error 8624 may occur with subquery that contains aggregate or computed columns =

Article ID: 290817

Article Last Modified on 10/7/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q290817



BUG #: 352229 (SHILOH)

BUG #: 101227 (SQLBUG_70)



SYMPTOMS
If you submit a query that contains an aggregate or other computed column inside of a subquery, SQL Server may return error 8624 while attempting to optimize the query. The error message is:

Server: Msg 8624, Level 16, State 8, Line 1

Internal SQL Server error.

The query will not run, and it is not possible to see the SHOWPLAN_ALL or SHOWPLAN_TEXT output for the query.



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

290211 How to obtain the latest SQL Server 2000 service pack

Hotfix information
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Version    File name --  8.00.0258  S80258i.exe Note Because of file dependencies, the most recent hotfix or feature that contains these files may also contain additional files.



WORKAROUND
If the computed expression is a MIN or MAX aggregate, you can replace the aggregate with a TOP 1 ... ORDER BY ASC or ORDER BY DESC clause, respectively.



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



MORE INFORMATION
The state reported in the error message indicates where in the code that this particular error occurs. For example, the state for this error is eight (8). This particular fix only addresses 8624 errors where the state is eight.

The following code sample demonstrates the problem, as well as the suggested workaround of using TOP. create table t (schedule nvarchar(3), lastdateentry smalldatetime, mileage char(1)) create table t1 (service_method varchar(3), transport_indicator varchar(1)) create table t2 (service_method varchar(3), transport_indicator varchar(1)) go create view v as select service_method, transport_indicator from t1 UNION all select service_method, transport_indicator from t2 go --This query returns error 8624 SELECT Count(*) FROM t join v on t.Schedule = v.Service_Method Where t.lastdateentry = (select max(lastdateentry) from t    where mileage = v.transport_indicator) go --This rewritten version of the query works fine SELECT Count(*) FROM t join v on t.Schedule = v.Service_Method Where t.lastdateentry = (select top 1 lastdateentry from t    where mileage = v.transport_indicator order by lastdateentry DESC)

Keywords: kbbug kbfix kbqfe kbsqlserv2000sp1fix KB290817

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.