日期:2014-05-19  浏览次数:20702 次

请教一个问题 select 语句
现   select   语句执行结果
select   bh   as   编号,mc   as   名称,sl   as   数量   from   table   where   .....
    编号         名称           数量
    0003         sfsdfs       1000
    2000         dssdds         300
    3000         eeeeee         28
    2590         ekjkjj         500

要求结果变为:
  记录号           编号         名称           数量
          1             0003         sfsdfs       1000
          2             2000         dssdds         300
          3             3000         eeeeee         28
          4             2590         ekjkjj         500
其中记录号   为查询以后的记录号   不是为原表中的记录号

------解决方案--------------------
select 记录号=identity(int,1,1), bh as 编号,mc as 名称,sl as 数量 into # from table where .....

select * from #
------解决方案--------------------
select identity(int,1,1) as '记录号 ',bh as 编号,mc as 名称,sl as 数量 into #t from table where .....
select * from #t;