AS – Rename output columns

Sometimes when you run a query you may want to rename the columns in the results. This is quite a simple process within SQL.

First you will need to know the source column names.

For example

USE AdventureWorks

GO

SELECT * FROM [HumanResources].[Department]

1

Or you can open up the table which gives the column names.

2

You can change the name of the column by using the below SYNTAX

[ SourceColumn Name] AS [DesiredOutputName]

SELECT [DepartmentID] AS ID,

[Name] AS [Department Name],

[GroupName] AS [Function],

[ModifiedDate] AS LastChangeDate

FROM [HumanResources].[Department]

3

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: