Knowledge Base

BUG: SELECT from View with UNION ALL and Aggregate Function AVs

Article ID: 191809

Article Last Modified on 10/3/2003


APPLIES TO


This article was previously published under Q191809
BUG #: 18230 (SQLBUG_65)

SYMPTOMS

You may receive a handled access violation (AV) if all of the following conditions are true:
  • You issue a SELECT statement against a view.

    -and-
  • That view uses UNION ALL to union a SELECT statement containing an aggregate function with another view.

    -and-
  • That other view also contains UNION ALL.

WORKAROUND

To work around this problem, do any one of the following:
  • Change any of the UNION ALL statements to a UNION.

    -or-
  • Eliminate the aggregate function from the SELECT statement in the outer view.

    -or-
  • Execute the Transact-SQL statements that make up the outer view directly (as opposed to selecting from the outer view).

STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5.


Additional query words: MIN MAX SUM AVG COUNT

Keywords: kbbug kbpending KB191809