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.

Leave a Reply


x

Interesting BlogPosts to read

How to get the MAX row with group by in LINQ query using C# ?
Below is a sample code snippet demonstrating how to retreive the max row with the group by in LINQ Q...
Webinar - The Shortcomings of SQL for SharePoint Sync
Redmond Magazine is hosting a webinar on the topic "The Shortcomings of SQL for SharePoint Sync" on ...
Using SQL "IN" Clause in LINQ Query
When using the SQL Query, we could use the IN keyword to find the item something like this SELECT *...