mssql sqlserver sql脚本中as关键字的用法和作用简介说明


摘要:
下文讲述sqlserver中as关键字的用法说明,如下所示:
实验环境:sql server 2008 R2


在平常的业务开发中,我们经常看见sql脚本中使用as,有些同事在实现同样的功能下添加as关键字,有些同事不添加as关键字,下文将着重讲述as 关键字在sqlserver中的功能。

as 关键字功能

as 关键字在sqlserver中的主要功能为:为列名 表名取别名

as 关键字举例说明

    select  
       [列名1] as [别名1],
       [列名2] as [别名2],
       [列名3] as [别名3]
    from [数据表] as [表别名]
        where    [条件]
     
     ---例:
      select infoA as A ,infoB as B
       from [maomao365.com] as t 
        where t.infoA ='Test'