SA0271 : The column alias syntax is not recommended |
![]() |
Using inefficient or non-standard syntax for column aliases can cause significant confusion and maintenance challenges.

Column aliases are often used to rename output columns in SELECT statements for clarity or to match application requirements. However, choosing the wrong syntax for these aliases can result in difficulties during query maintenance and lead to inconsistencies across queries. Both readability and adherence to standard SQL conventions are at risk when non-standard aliasing methods are used.
For example:
1-- Example of problematic query syntax 2SELECT ColumnName AS alias FROM TableName;
While the example above uses a valid alias syntax, not all developers follow consistent practices. Some might use non-standard syntax or omit the keyword AS, leading to potential ambiguity, especially when visualizing complex queries. SQL Server accepts different methods, but inconsistency can make the SQL codebase difficult to manage.
-
Readability of queries diminishes with inconsistent alias syntax, making it hard for others to understand the intent quickly.
-
Non-standard aliasing may lead to errors during code maintenance and integration, especially if assumptions about aliasing conventions vary among developers.

This guidance provides instructions on correcting column alias syntax to adhere to best practices in SQL queries.
Follow these steps to address the issue:
-
Identify all instances of column aliases in your SQL queries that do not follow standard practices. Look for missing keyword AS, inconsistencies, or non-standard usage.
-
Rewrite each column alias to consistently use the AS keyword. This enhances clarity and adheres to SQL Server conventions.
-
Ensure that all column aliases are descriptive and adhere to a naming convention that enhances readability and maintains uniformity across the codebase.
-
Review your changes to confirm improved consistency and clarity, thus facilitating better understanding and future maintenance of the queries.
For example:
1-- Corrected example adhering to best practices 2SELECT ColumnName AS AliasName FROM TableName;

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

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 |

The rule does not need Analysis Context or SQL Connection.


Design Rules

There is no additional info for this rule.

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 |

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 |
