Click or drag to resize

SA0198 : Usage of deprecated GROUP BY ALL syntax encountered

The topic describes the SA0198 analysis rule.


Usage of deprecated GROUP BY ALL syntax encountered


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.

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

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.


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


Rule has no parameters.


The rule does not need Analysis Context or SQL Connection.


Design Rules, New Rules

Additional Information

There is no additional info for this rule.

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

Analysis Results

1SA0198 : Usage of deprecated GROUP BY ALL syntax encountered.70
See Also

Other Resources