- In this article we will explain how to use AS Keyword in SQL Server OR what is AS Keyword in SQL Server with Example.
SQL AS is used to assign an alias (temporary name) to the column or a table. It makes easy readable of query results and allows the developer to label results more accurately without permanently renaming table columns.
Alias Column Syntax:
SELECT column_name AS alias_name
Alias Table Syntax:
FROM table_name AS alias_name;
The Following SQL Statement selects record without using Alias from Student Table.
select * from Student
Alias for Columns Examples
The following SQL statements use column Alias.
select id AS StudentID,
address1 as [Address],
Alias for Tables Example
The following SQL statements use table Alias.
select s.id AS StudentID,s.Name,s.Mobile,s.address1 as [Address],s.age,f.amount
from Student as s
left join Fee as f on s.id=f.StudentId
I hope this article will help to you.