Click or drag to resize

SA0018 : Support for constants in ORDER BY clause have been deprecated

The topic describes the SA0018 analysis rule.

Message

Support for constants in ORDER BY clause have been deprecated

Description

This rule checks for use of ORDER BY clause specifying constants as sort columns. Support for this syntax has been deprecated.

Scope

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

Parameters
NameDescriptionDefault Value
RuleSuppressMark

Suppress rule reporting a rule violation in case a comment containing the value of this parameter is found close to the source of violation.

IGNORE:SA0018

IgnoreOredrByInOverClause

Parameter specifies if to ignore order by a constant when it is used inside an OVER clause.

yes

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
 1CREATE PROCEDURE HumanResources.uspGetAllEmployees
 2AS 
 3SET NOCOUNT ON;
 4
 5SELECT LastName,
 6       FirstName,
 7       JobTitle,
 8       Department
 9FROM HumanResources.vEmployeeDepartment
10ORDER BY 2 -- numeric constant is allowed
11
12SELECT au_id
13FROM dbo.authors
14ORDER BY 'a',  -- string constants are deprecated
15         NULL  -- NULL is deprecated
16
17
18SELECT au_id
19FROM dbo.authors
20ORDER BY 'a',  -- string constants are deprecated and NULL-s are deprecated, 
21                NULL   -- but will be ignored because of the rule suppression mark here -> IGNORE:SA0018

Analysis Results

 MessageLineColumn
1SA0018 : Support for constants in ORDER BY clause have been deprecated.149
2SA0018 : Support for constants in ORDER BY clause have been deprecated.159
See Also

Other Resources