FIX: Errors with Procedures Containing Aggregates and a HAVING Clause

ID: Q194664


The information in this article applies to:

BUG #: 16906 (SQLBUG_65)

SYMPTOMS

A stored procedure that contains an aggregate in the HAVING clause may cause error 107 or a handled access violation (AV) if the procedure must be recompiled or reresolved. The procedure will be recompiled when the server is restarted or the procedure is otherwise flushed from cache, or when the WITH RECOMPILE clause is used. A reresolution occurs when a schema change is made to any of the objects referenced in the stored procedure.

The following is error 107:

Msg 107: The column prefix '' does not match with a table name or alias name used in the query.


WORKAROUND

To avoid the error 107 or handled access violation, do not use an aggregate in the HAVING clause. As an alternative, you can drop and re-create the procedure after starting the server or after schema changes are made to any of the underlying objects.


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5. This problem has been corrected in U.S. Service Pack 5a for Microsoft SQL Server version 6.5. For information about downloading and installing the latest SQL Server Service Pack, see http://support.microsoft.com/support/sql/.

For more information, contact your primary support provider.

Additional query words: prodsql


Keywords          : SSrvGPF SSrvProg SSrvTran_SQL kbbug6.50 kbfix6.50.SP5 
Version           : winnt:6.5
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: May 4, 1999