Cloud Training (Online)




Column Alias and Square brackets in SQL Query.

When we want to specify a alias for a column in SQL Query , we tend to use the double quotes or single quotes. For example , if we want to set the alias name of the column “Name” to “Department Name” , we can do it in the following ways.

SELECT Name as "Department Name" FROM HumanResources.Department

SELECT Name as 'Department Name' FROM HumanResources.Department

SQL Server also provides a proprietary syntax of using the square brackets in providing the alias name with spaces as shown below.

SELECT Name as [Department Name] FROM HumanResources.Department