select IDENTITY(int,1, 1) as XH,name from tmpTbl

解决方案 »

  1.   

    select IDENTITY(int,1, 1) as XH,name 
    into #aaa
    from tmpTblselect * from #aaa
      

  2.   

    IDENTITY必须和into语句一起使用,但是我的目标其实是想将选择的
    数据插入到一个已经有了数据的表中
    insert into strudents(class,name,Number)
    select class,name,IDENTITY(int,1,1) from tmpTbl.
      

  3.   

    加一个新列,然后declare @no int
    update table set 新列 = @no,@no = @no +1