Introduction:

  • In this article we will explain how to use AS Keyword in SQL Server OR what is AS Keyword in SQL Server with Example.

Description: 

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
FROM table_name;


  • Alias Table Syntax:

SELECT column_name(s)
FROM table_name AS alias_name;


The Following SQL Statement selects record without using Alias from Student Table.

select * from Student

Result:




AS Keyword:

  • Alias for Columns Examples

The following SQL statements use column Alias.

select id AS StudentID,
Name
Mobile,
address1 as [Address],
age
from Student


Result:



  • 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

Result:



I hope this article will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Welcome to SQL Tutorials Point

Don't have an account? Click here to Create a new account, it takes less than a minute.