日期:2014-05-17 浏览次数:20707 次
create proc ccgc @p_aa), -- 4位 @p_bb varchar(20), -- 20位用 @p_ksrq varchar(8) = '', @p_jzrq varchar(8) = '', as ... insert into #bb exec dbo.up_this @p_aa = @p_aa, -- char(4) @p_bb = @p_bb, -- varchar(20) @p_yigerq = @p_ksrq, -- varchar(8) @p_cc = '', -- char(1) @p_dd = '', -- varchar(255) @p_ee = '', -- varchar(255) @p_ff = '', -- varchar(255) @p_gg = '', -- varchar(255) ...
declare @begindate datetime set @begindate='2012-08-01' declare @enddate datetime set @enddate='2012-08-10' while (@begindate<=@enddate) begin --select @begindate insert into #bb exec dbo.up_this @p_aa = @p_aa, -- char(4) @p_bb = @p_bb, -- varchar(20) @p_yigerq = @p_ksrq, -- varchar(8) @p_cc = '', -- char(1) @p_dd = '', -- varchar(255) @p_ee = '', -- varchar(255) @p_ff = '', -- varchar(255) @p_gg = '', -- varchar(255) set @begindate=dateadd(d,1,@begindate) end
------解决方案--------------------
declare @p_ksrq varchar(10),@p_jzrq varchar(10),@rq varchar(10),@i int select @p_ksrq='2012-08-01',@p_jzrq='2012-08-15',@i=0 while @i<=datediff(day,@p_ksrq,@p_jzrq) begin set @rq=dateadd(day,@i,@p_ksrq) select @rq --@rq为你需要查询的日期 set @i=@i+1 end
------解决方案--------------------
declare @begin_date varchar(10) declare @end_date varchar(10) declare @date varchar(10) declare @i int set @begin_date='2012-08-01' set @end_date='2012-08-15' set @i=0 while @i<=datediff(day,@begin_date,@end_date) begin select @date=dateadd(day,@i,@begin_date) print @date set @i=@i+1 end