Click or drag to resize

SA0008 : Deprecated syntax string = expression_alias

The topic describes the SA0008 analysis rule.

Message

Deprecated syntax string = expression_alias

Description

This rule checks T-SQL script for use of column aliasing where the name of the expression uses a string value. The syntax is deprecated and it is recommended to use quoted identifiers instead.

The following syntax is deprecated:

SQL
1SELECT 'alias_for_col' = au_id + au_id
2FROM dbo.authors

Recommended alternatives are:

1expression [AS] column_alias 
2expression [AS] [column_alias]
3expression [AS] "column_alias"
4expression [AS] 'column_alias'
5column_alias = expression

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, Deprecated Features

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1-- Deprecated alias syntax is used here
 2SELECT     'alias_for_col'=au_id+au_id
 3FROM       dbo.authors
 4
 5-- Deprecated alias syntax is used here,but ignored, because all rules at the violation line are suppressed
 6SELECT     'alias_for_col'=au_id+au_id, au_id --IGNORE:*(LINE)
 7FROM       dbo.authors
 8
 9-- OK
10SELECT     au_id+au_id AS alias_for_col
11FROM       dbo.authors
12
13-- OK
14SELECT     au_id+au_id AS [alias_for_col]
15FROM       dbo.authors
16
17-- OK
18SELECT     au_id+au_id AS "alias_for_col"
19FROM       dbo.authors
20
21-- OK
22SELECT     au_id+au_id AS 'alias_for_col'
23FROM       dbo.authors
24
25-- OK
26SELECT     column_alias=expression
27FROM       dbo.authors

Analysis Results

 MessageLineColumn
1SA0008 : Deprecated syntax string = expression_alias.211
See Also

Other Resources