HomeSQL ServerColumn Alias and Square brackets in SQL Query.

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

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...