set rowcount 10000 select identity(int,0,1) as id into # from sysobjects a,syscolumns b set rowcount 0insert into 表2 select (a.beginnum+b.id) from 表1 a,# b where a.beginnum+b.id<=b.endnumdrop table #
to:libin_ftsafe(子陌红尘:当libin告别ftsafe) 对不起,对于上面的语句还有个问题要问: select identity(int,0,1) as id into # from sysobjects a,syscolumns b 这句在我的数据库里只有20多W条记录,如果我超过100W条,应该怎么改?
--建立测试环境 create table #tb(beginnum int,endnum int) insert into #tb select 112345,113345 union all select 248175,248317 --测试 select identity(int,1,1) TID into #temp from syscolumns a,syscolumns --select count(*) from #temp每一个beginnum endnum能插入的最大记录数,要是更多就用更多的表关联 select * from #temp,#tb where TID between beginnum and endnum --删除测试环境 drop table #tb drop table #temp
select identity(int,0,1) as id into # from sysobjects a,syscolumns b
set rowcount 0insert into 表2
select (a.beginnum+b.id) from 表1 a,# b where a.beginnum+b.id<=b.endnumdrop table #
我用了你的方法,我把set rowcount 10000改为200000
为什么在insert到 表2时只能插入10000条数据?
----------------------------------------------------------------------
select count(*) from # 得到多少?
我以为select identity(int,0,1) as id into # from sysobjects a,syscolumns b
这句#后面少了表名.我自己加了个表面
有几个表数据一旦运行起来,一年内数据可能是几百W条.如果系统有要求对此表(或能联合几个表)进行明细查询,数据汇总时,怎么考虑性能问题呢?我之前有做过按周来分表,每周的数据只插入到本周产生的新表中,但这样在报表明细查询时,非常麻烦,而已速度应该也很慢,请问遇到以上问题时怎么解决的?
select identity(int,0,1) as id into # from sysobjects a,syscolumns b
这句在我的数据库里只有20多W条记录,如果我超过100W条,应该怎么改?
--建立测试环境
create table #tb(beginnum int,endnum int)
insert into #tb
select 112345,113345 union all
select 248175,248317
--测试
select identity(int,1,1) TID into #temp from syscolumns a,syscolumns
--select count(*) from #temp每一个beginnum endnum能插入的最大记录数,要是更多就用更多的表关联
select * from #temp,#tb
where TID between beginnum and endnum
--删除测试环境
drop table #tb
drop table #temp