SA0199 : Usage of deprecated COMPUTE clause encountered

The topic describes the SA0199 analysis rule.

Message

Usage of deprecated COMPUTE clause encountered

Description

The rule checks and reports usages of the deprecated COMPUTE clause.

The COMPUTE and COMPUTE BY clauses are deprecated and are not supported in SQL Server 2012 and later.

How to fix

Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use ROLLUP instead.

The result set of a ROLLUP operation has functionality similar to that returned by a COMPUTE BY. However, ROLLUP has the some advantages:

– ROLLUP returns a single result set while COMPUTE BY returns multiple result sets that increase the complexity of application code.

– ROLLUP can be used in a server cursor while COMPUTE BY cannot.

– The query optimizer can sometimes generate more efficient execution plans for ROLLUP than it can for COMPUTE BY.

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
1SELECT Country, State, City, Population 
2FROM Country C 
3ORDER BY Name, State, City
4COMPUTE SUM(Population) BY Country, State
5
6SELECT Country, State, City, SUM (Population) AS Population 
7FROM Country C
8GROUP BY Country, State, City
9WITH ROLLUP

Analysis Results
  Message Line Column
1 SA0199 : Usage of deprecated COMPUTE clause encountered. 4 0
See Also

Other Resources