SA0271 : The column alias syntax is not recommended

The topic describes the SA0271 analysis rule.

Message

The column alias syntax is not recommended

Description

This rule checks T-SQL statements and reports usages of any of the configured as not recommended syntax for column aliases.

Scope

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

Parameters
Name Description Default Value
AllowExpressionAsKeywordIdentifierColumnAlias

Allows column alias expression syntax: expression AS column_alias

yes

AllowExpressionAsKeywordStringColumnAlias

Allows column alias expression syntax: expression AS ‘column_alias’

yes

AllowExpressionIdentifierColumnAlias

Allowscolumn alias expression syntax: expression column_alias

no

AllowExpressionStringColumnAlias

Allows column alias expression syntax: expression ‘column_alias’

no

AllowIdentifierColumnAliasAssignmentExpression

Allows column alias expression syntax: column_alias = expression

no

AllowStringColumnAliasAssignmentExpression

Allows column alias expression syntax: ‘column_alias’ = expression

yes

RecommendedSyntaxMessageDescription

The recommended column alias syntax description.

expression AS column_alias

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
SQL
 1select  
 2    expression AS column_alias, 
 3    expression AS [column_alias],
 4    expression AS "column_alias",
 5    expression AS 'column_alias',
 6    expression   column_alias ,
 7    expression   [column_alias],
 8    expression   "column_alias",
 9    expression   'column_alias',
10    column_alias = expression,
11    'column_alias' = expression
12from b

Analysis Results

  Message Line Column
1 SA0271 : The column alias syntax is not recommended. Use expression AS column_alias instead. 5 18
2 SA0271 : The column alias syntax is not recommended. Use expression AS column_alias instead. 6 17
3 SA0271 : The column alias syntax is not recommended. Use expression AS column_alias instead. 7 17
4 SA0271 : The column alias syntax is not recommended. Use expression AS column_alias instead. 8 17
5 SA0271 : The column alias syntax is not recommended. Use expression AS column_alias instead. 10 4
See Also

Other Resources