从开始日期到结束日期的循环

/*
从开始日期到结束日期计算进销存
*/
declare @str_dt datetime,
  @end_dt datetime,
  @temp_dt varchar(10),
  @i  int

select @str_dt='20090401',@end_dt='20090407'

set @i=DATEDIFF ( day , @str_dt , @end_dt )
while @i>=0
begin
 set @temp_dt=convert(varchar(10),@str_dt,120)
 execute sp_calc_jxc_da @temp_dt
 set @str_dt=DATEADD ( day , 1, @str_dt )
 set @i=DATEDIFF ( day , @str_dt , @end_dt )  
end

posted @ 2009-04-07 09:46  kuailewangzi1212  阅读(423)  评论(0编辑  收藏  举报