DF198: COMPUTE or COMPUTE BY clause is used.
Last modified: May 28, 2025
The topic describes the DF198 T-SQL code analysis rule.
Category
DEPRECATED
Message
COMPUTE or COMPUTE BY clause is used.
Description
It is not recommended to use the COMPUTE and COMPUTE BY clauses as they are deprecated and not supported in SQL Server 2012 and later.
Noncompliant code example
CREATE TABLE population
(
country VARCHAR(100),
[state] VARCHAR(100),
city VARCHAR(100),
[population (in millions)] FLOAT
)
GO
INSERT INTO POPULATION VALUES('USA', 'Texas','San Antonio',1.5)
INSERT INTO POPULATION VALUES('USA', 'Texas','Huston',2.3)
INSERT INTO POPULATION VALUES('USA', 'California','Los Angeles',3.9)
INSERT INTO POPULATION VALUES('USA', 'California','San Diego',1.4)
INSERT INTO POPULATION VALUES('India', 'Karnataka','Bangalore',9.5)
INSERT INTO POPULATION VALUES('India', 'Karnataka','Manipal',1.5)
INSERT INTO POPULATION VALUES('India', 'Delhi','East Delhi',9 )
INSERT INTO POPULATION VALUES('India', 'Delhi','South Delhi',8 )
GO
SELECT country, [state], city, [population (in millions)]
FROM POPULATION
ORDER BY country, [state], city
COMPUTE SUM([population (in millions)]) BY country,[state]
GO
Compliant solution
SELECT country,[state],city,
SUM ([population (in millions)]) AS [population (in millions)] FROM POPULATION
GROUP BY country,[state],city
WITH ROLLUP
GO
Was this page helpful?
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.