http://expert.csdn.net/Expert/topic/2437/2437014.xml?temp=.67857
交流]自增号1: 自增列   类型为:int identity(1,1)  当然也可以是bigint,smallint 
   eg: create table tbName(id int identity(1,1),description varchar(20))
   或在用企业管理器设计表字段时,将字段设为int,将标识设为是,其它用默认即可2: 查询时加序号:
  a:没有主键的情形:
   Select identity(int,1,1) as iid,* into #tmp from TableName
   Select * from #tmp
   Drop table #tmp
  b:有主键的情形:
   Select (Select sum(1) from TableName where KeyField <= a.KeyField) as iid,* from TableName a

解决方案 »

  1.   

    select identity(int,1,1) as id ,* into #t from table
    select * from #tdrop table #t
      

  2.   

    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
    select * from #temp
      

  3.   

    select id=identity(int,1,1) ,* into #ccc from 表名
    select * from #ccc
      

  4.   

    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
    select * from #temp
      

  5.   

    --如果你的表中有主键,可以用:select 序号=(select sum(1) from 表 where 主键<=a.主键)
      ,*
    from 表 a
    order by 主键
      

  6.   

    如果没有的话,就只能用临时表.select 序号=IDENTITY(int, 1,1),* into #t from 表
    select * from #t