Click or drag to resize

SA0119 : Consider aliasing all table sources in the query

The topic describes the SA0119 analysis rule.

Message

Consider aliasing all table sources in the query

Description

The rule alerts for not aliased table sources in the FROM clause of SELECT, UPADTE and DELETE statements.

Consider aliasing all table sources in the query.

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:SA0119

IgnoreSingleTableSources

The queries accessing single tables will be ignored.

yes

IgnoreTableValuesFunctions

The not aliased table valued functions will be ignored.

yes

IgnoreSystemObjects

The not aliased system tables or views will be ignored.

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
SQL
 1SELECT * 
 2FROM Sales.Customer
 3INNER JOIN Sales.vStoreWithAddresses AS sa 
 4    ON CustomerID = sa.BusinessEntityID
 5WHERE TerritoryID = 5
 6
 7SELECT * 
 8FROM Sales.Customer /*IGNORE:SA0119*/
 9INNER JOIN Sales.vStoreWithAddresses AS sa 
10    ON CustomerID = sa.BusinessEntityID
11WHERE TerritoryID = 5
12
13SELECT *
14FROM HumanResources.Employee 
15UNION
16SELECT *
17FROM HumanResources.Employee 
18OPTION (MERGE UNION); 
19
20SELECT * FROM Sales.SalesOrderHeader WITH (NOLOCK)

Analysis Results

 MessageLineColumn
1SA0119 : Table source does not have an alias. Consider aliasing all table sources in the query.211
See Also

Other Resources