BUG: ANSI Group By With > 16 Columns Gives Inconsistent Error (155893)



The information in this article applies to:

  • Microsoft SQL Server 6.0
  • Microsoft SQL Server 6.5

This article was previously published under Q155893

SYMPTOMS

A Group By clause with more than 16 non-aggregate columns can cause 2 different errors depending on the number of columns. If there are 17 non- aggregate columns, the following error will be returned:
Msg 415, Level 16, State 1
The current query would require an index on a work table to be built
with 15 keys. The maximum allowable number of keys is 16.

If there are more than 17 non-aggregate columns the following error will be returned:
Msg 253, Level 16, State 1
Maximum number of group-by expressions exceeded (16 max, 17 found).

WORKAROUND

  1. Rewrite query such that no more than 16 columns appear in the Group By clause.
  2. Use trace flag 204.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.0 and 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The 415 error message reports the number of key columns incorrectly as 15.

The 253 error message always reports that 17 non-aggregate columns were found no matter how many there actually are in the Group By clause.

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbBug KB155893