Page 164 - SQL
P. 164
Different Versions of SQL
You can use single quotes ('), double quotes (") and square brackets ([]) to create an alias in
Microsoft SQL Server.
SELECT
FName AS "First Name",
MName AS 'Middle Name',
LName AS [Last Name]
FROM Employees
Both will result in:
First Name Middle Name Last Name
James John Smith
John James Johnson
Michael Marcus Williams
This statement will return FName and LName columns with a given name (an alias). This is achieved
using the AS operator followed by the alias, or simply writing alias directly after the column name.
This means that the following query has the same outcome as the above.
SELECT
FName "First Name",
MName "Middle Name",
LName "Last Name"
FROM Employees
First Name Middle Name Last Name
James John Smith
John James Johnson
Michael Marcus Williams
However, the explicit version (i.e., using the AS operator) is more readable.
If the alias has a single word that is not a reserved word, we can write it without single quotes,
double quotes or brackets:
SELECT
FName AS FirstName,
LName AS LastName
FROM Employees
https://riptutorial.com/ 146

