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

解决方案 »

  1.   

    use pubsSELECT IDENTITY(smallint, 1, 1) AS job_num, 
       emp_id AS emp_num, 
       fname AS first, 
       minit AS middle, 
       lname AS last,    
       job_lvl AS job_level, 
       pub_id, 
       hire_date
    INTO employees 
    FROM employeeselect * from  employees
      

  2.   

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

  3.   

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

  4.   

    我也想问一下,如果不写成存储过程的形式,能否实现,像oracle一样,只用rownum之类的东西直接写在sql语句里的方法