简体   繁体   中英

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.

CREATE VIEW vw_RenameTable
AS
Begin

   Select GoodName1 = DumbName1
          ,GoodName2 = DumbName2
   From MyTable

End

A view would be the natural answer to the question. But, if you want to access the columns in the same table, you can use computed columns:

alter table mytable add bettercolumn as [Bad Ugly Name];

You can then use the computed column in a select on the same table .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM