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  FROM HumanResources.Department

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
Pin It

Leave a Reply

Your email address will not be published. Required fields are marked *