SA0198 : Usage of deprecated GROUP BY ALL syntax encountered

The topic describes the SA0198 analysis rule.

Message

Usage of deprecated GROUP BY ALL syntax encountered

Description

The rule checks and reports usages of the deprecated GROUP BY ALL syntax.

The GROUP BY ALL clause specifies to include all groups in the results regardless of whether they meet the search criteria in the WHERE clause. Groups that don’t meet the search criteria have NULL for the aggregation.

This syntax is deprecated and is provided for backward compatibility only. It will be removed in a future version of SQL Server.

The GROUP BY ALL syntax is not supported in queries that access remote tables if there is also a WHERE clause in the query and will fail on columns that have the FILESTREAM attribute.

How to fix

Avoid using this syntax in new development work, and plan to modify applications that currently use this syntax.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
20 minutes per issue.
Categories

Design Rules, Deprecated Features, Bugs

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1-- Deprecated GROUP BY ALL clause used
 2SELECT     
 3        ColumnA ,
 4        COUNT(DISTINCT ColumnB) 
 5FROM    T
 6WHERE   ColumnC > 1000
 7GROUP BY ALL  
 8        ColumnA
 9
10-- The statement is equivalent as the above         
11SELECT  ColumnA ,
12        COUNT(DISTINCT CASE WHEN ColumnC > 1000 THEN ColumnB END) 
13FROM    T
14GROUP BY 
15        ColumnA

Analysis Results
  Message Line Column
1 SA0198 : Usage of deprecated GROUP BY ALL syntax encountered. 7 0
See Also

Other Resources