Aliasing column names in SQL server

  • Is there a way in SQL server to alias column names for a particular table and store the aliases somewhere such that you can access the aliases while querying? I have a table where I cannot change column names and I am trying to figure out if there is a way to alias them to make them more user friendly.

  • one way would be to create a view and then put the aliases there.

    CREATE VIEW vw_SomeView

    AS

    SELECT field1 AS NewName

    ,field2 AS NewName2...

    FROM MyTable

    ...

    Then reference the view instead of the table in your code.

  • Agreed. I think this is the perfect use for a view.

    Watch my free SQL Server Tutorials at:
    http://MidnightDBA.com
    Blog Author of:
    DBA Rant – http://www.MidnightDBA.com/DBARant

    Minion Maintenance is FREE:

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply