Click or drag to resize

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.

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.

Categories

Design Rules, New Rules

Additional Information

There is no additional info for this rule.

Example Test Script
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

 MessageLineColumn
1SA0199 : Usage of deprecated COMPUTE clause encountered.40
See Also

Other Resources