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

Article translations Article translations
Article ID: 290817 - View products that this article applies to.
This article was previously published under Q290817
BUG #: 352229 (SHILOH)
BUG #: 101227 (SQLBUG_70)
Expand all | Collapse all

On This Page


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 available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

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.


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


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


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))
create view v as 
select service_method, transport_indicator from t1
select service_method, transport_indicator from t2
--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)
--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)


Article ID: 290817 - Last Review: October 7, 2005 - Revision: 4.4
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition
kbautohotfix kbhotfixserver kbbug kbfix kbqfe kbsqlserv2000sp1fix KB290817

Give Feedback


Contact us for more help

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