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

Leave A Reply

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

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...