日期:2014-05-19  浏览次数:20499 次

请教数据插入的优化
例如说我要给给数据库插入数据(日期字段),从 "2001-1-1 "到 "2100-1-1 "(按月递增),那么我是不是只能通过循环,逐个插入呢?有没有更好的方法呢?(现在要INSERT   1200次)

------解决方案--------------------
create table test(months datetime)
go

set rowcount 1200
select identity(int,0,1) as id into # from sysobjects a,sysobjects b
set rowcount 0

insert into test(months)
select dateadd(m,id, '2001-01-01 ') from #

select * from test
go


drop table test,#
go
------解决方案--------------------
set rowcount 1000000
select identity(int,0,1) as id into # from sysobjects a,sysobjects b, syscolumns c, syscolumns d
set rowcount 0