循环初始化主从表数据

初始化主表数据
declare @i int 
set @i=2010 
while @i<2030 
begin 
insert into OA_Merchants_SaleStatusMain ([Year]) values(@i) 
set @i=@i+1 
end 
初始化从表
drop table #tempt1;
select * into #tempt1  from OA_Merchants_SaleStatusDetails
declare @a int
set @a=5 
while @a<25 
begin
   insert into OA_Merchants_SaleStatusDetails([MainID]
      ,[Month]
      ,[CompanyProportion]) select @a,[Month]
      ,[CompanyProportion] from #tempt1
      set @a=@a+1 
end

 

posted @ 2015-03-12 15:45  JJ.Net  阅读(122)  评论(0)    收藏  举报