Automatically Generated Aliases

Projected columns that are not aliased will produce an output column with the same name as the column itself. The following query will produce two output columns named CategoryID and CategoryName.

 

SELECT CategoryID, CategoryName FROM Categories

 

If an expression is used without an alias, the resulting output column will be named expr{n}, where n is a three-digit integer. The following query will produce one output column named expr000.

 

SELECT CategoryID + 1 FROM Categories

 

Aggregated columns without an alias will also produce output columns named expr{n}. The following query will produce two output columns named expr000 and expr001.

 

SELECT MAX(UnitPrice), MIN(UnitPrice) FROM Products

 

Backwards compatibility. This behavior is different for data models that function at compatibility level of 0x109700 (backwards-compatible). For these models, aggregated columns with no alias will produce output columns named as {aggregated column name}[_n] where aggregated column name is the name of the column being aggregated, optionally followed by an integer qualifier to make output column names unique.

 

The following query will produce one output column named UnitPrice.

 

SELECT MAX(UnitPrice) FROM Products

 

The following query will instead produce two output columns named UnitPrice and UnitPrice_1.

 

SELECT MAX(UnitPrice), MIN(UnitPrice) FROM Products