Friday, 6 February 2009

Explain ALIASES clause in SQL Server.

The ALIASES clause is used to give another name for a column or a table. This is mostly used to show the output meaningful.

Ex :
Using ALIAS in a Column

Select EmployeeName as FullName, EmployeeID as ID from Employees

This Query will display the column ‘Employee Name’ as ‘Full Name’ and ‘Employee ID’ as ‘ID’ from the table “Employees”.

Using ALIAS in a Table

Select EmployeeName, EmployeeID from Employees as Resources

This Query will select the columns ‘Employee Name’ and ‘Employee ID’ from the table “Employees” and display as a “Resource” table.

Using WHERE clause with SQL ALIAS

Select EmployeeName as FullName, EmployeeID as ID from Employees where EmployeeID > 250

This Query will select the ‘Employee Name’ and ‘Employee ID’ from “Employees” table and display as ‘Full Name’ and ‘ID’ with a condition of ‘Employees ID’ greater than 250.

Labels:


Bookmark this Blog in your Favorites

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home