SQL Alias (Table/View/Column Name Alias)

A-Z of Mircrosoft SQL

Main Page Introduction SSMS Acronym's used in SQL SQL Commands SQL Functions SQL Store Procedures SQL Views SQL Triggers SQL Operators SQL - Adding Comments SQL Alias SQL Joins SQL - Building Basic Scripts SQL - Execution Plan Questions or Suggestions
H1B Jobs- Visual Reports

SQL Examples

Arithmetic Operators Comparision Operators Logical Operators Bitwise Operators String Functions Date Functions Numeric Functions


SQL Alias

Alias= An assumed Name or Identity

A lot of times we need to change the Column Name or table Name temporarily , this is where we can use Alias

This is very useful while joining multiple tables in RDBMS

Column Name - Alias

SENARIO- Your company asked you to give a report , with Person details. But they wanted to rename FirstName as FNAME , LastName as LNAME. You can do the below query.

Here we can see three ways of creating a Alias Name
1) Use 'AS' and rename it.
2) Simply rename it with a space in between.
3) Use '=' sign, but note that the Alias name should come first in this case.

SQL- Using a Alias column name

Table/View Name - Alias

Alias for Table / View names are very helpful when we join two or more tables/ views.This helps us specify the column is in which table easily.

In the below example notic how we name one table A another table B and use it before column Names

SQL- Using a Alias Table name

Next Stop: SQL Joins