我想设置查询语句,将当前月份设置为列的标题,如
select A.date as '当前年月'from A因为当前年月是随时间变换的,可以随着显示2011.7,2011.8,2011.9....应该怎么设置呢

解决方案 »

  1.   


    exec('select A.date as ['+convert(varchar(6),getdate(),120)+'] from A')
      

  2.   

    +exec('select A.date as ['+convert(varchar(6),getdate(),112)+'] from A')
      

  3.   


    declare @sql varchar(4000)
    set @sql = 'select A.date as ['+convert(varchar(6),getdate(),112)+'] from A'
    exec(@sql)
      

  4.   

    有没有select就能显示,不用在exec中呢
      

  5.   

    有没有可能直接在select下显示的,无需exec执行?