SELECT top 35 IDENTITY(int, 1,1) AS ID_Num
into # from sysobjects,sysobjectscreate table #1(id int,zh int)
declare @i int
set @i=1
while @i<6
begin
  insert into #1
  select top 7 ID_Num,@i
  from  # left join #1 on id=ID_Num where id is null
  order by newid()
 set @i=@+1
end

解决方案 »

  1.   

    6724520,六百多万条记录那!写进数据库,在5秒内,我想不大可能吧。
    我用了一分多钟。你用什么方法?写出来大家学习学习!select top 35 identity(int,1,1) id into #t from sysobjectsselect a.id as id1,b.id as id2,c.id as id3,d.id as id4,e.id as id5,f.id as id6,g.id as id7 into tab
    from #t a,#t b,#t c,#t d,#t e,#t f,#t g
    where a.id<b.id and b.id<c.id and c.id<d.id and d.id<e.id and e.id<f.id and f.id<g.iddrop table #t
      

  2.   

    用C++标准类模板生成一个流,把这个流文件当作数据库用,就可以了
    filebuf buffer;
    ostream output(&buffer);
    buffer.open("haoma.txt",ios::out);
    Table1->Close();
    char *haoma[35];
    //在这里把"01"-"35"写进数组里
    for(i1=1;i1<=29;i1++)
       { for(i2=i1+1;i2<=30;i2++)
          { for(i3=i2+1;i3<=31;i3++)
             for(i4=i3+1;i4<=32;i4++)
              for(i5=i4+1;i5<=33;i5++)
               for(i6=i5+1;i6<=34;i6++)
                for(i7=i6+1;i7<=35;i7++)
                 output<<haoma[i1-1]<<haoma[i2-1]<<haoma[i3-1]<<haoma[i4-1]<<haoma[i5-1]<<haoma[i6-1]<<haoma[i7-1]<<endl;
          }
       }