1,建序数表
select top 8000 identity(int,1,1) as N into numtab from 
(select top 100 id=1  from sysobjects) as a,
(select top 100 id=1  from sysobjects) as b,
(select top 100 id=1  from sysobjects) as cselect * from numtab

解决方案 »

  1.   

    select top 8000 (select sum(1) from sysobjects where id<=tem.id) id from sysobjects tem
      

  2.   

    --1.创建一个合并的函数
    alter function fmerg(@id int)
    returns varchar(8000)
    as
    begin
    declare @str varchar(8000)
    declare @i int
    set @str=''
    set @i = 1
    while @i <= @id
    begin
    set @str=@str+','+cast(@i as varchar)
    set @i = @i+1
    end
    set @str=right(@str,len(@str)-1)
    return(@str)
    End
    go--调用 Select dbo.fmerg(10)  结果为:  1,2,3,4,5,6,7,8,9,10
      

  3.   

    select identity(int,1,1) F1 into #temp from sysobjects,syscolumns,systypes
    select * from #temp
    drop table #temp
      

  4.   

    select top 8000 identity(int,1,1) F1 into #temp from sysobjects,syscolumns,systypes
    select * from #temp
    drop table #temp