日期:2014-05-18 浏览次数:20678 次
declare @dt varchar(30),@today varchar(30) select @dt ='2012-05-01',@today=left(convert(varchar(30),getdate(),120),10) while @dt<@today begin exec P_Wms_StockDailyState @dt set @dt=left(convert(varchar(30),DATEADD(day,1,@dt),120),10) waitfor delay '00:00:01' end --是这个意思么
------解决方案--------------------
--测试结果: declare @dt varchar(30),@today varchar(30) select @dt ='2012-05-01',@today=left(convert(varchar(30),getdate(),120),10) while @dt<@today begin exec P_Wms_StockDailyState @dt set @dt=left(convert(varchar(30),DATEADD(day,1,@dt),120),10) waitfor delay '00:00:01' end --输出: exec P_Wms_StockDailyState '2012-05-01' exec P_Wms_StockDailyState '2012-05-02' exec P_Wms_StockDailyState '2012-05-03' exec P_Wms_StockDailyState '2012-05-04' exec P_Wms_StockDailyState '2012-05-05' exec P_Wms_StockDailyState '2012-05-06' exec P_Wms_StockDailyState '2012-05-07' exec P_Wms_StockDailyState '2012-05-08' exec P_Wms_StockDailyState '2012-05-09' exec P_Wms_StockDailyState '2012-05-10' exec P_Wms_StockDailyState '2012-05-11' exec P_Wms_StockDailyState '2012-05-12' exec P_Wms_StockDailyState '2012-05-13' exec P_Wms_StockDailyState '2012-05-14' exec P_Wms_StockDailyState '2012-05-15' exec P_Wms_StockDailyState '2012-05-16' exec P_Wms_StockDailyState '2012-05-17' exec P_Wms_StockDailyState '2012-05-18' exec P_Wms_StockDailyState '2012-05-19' exec P_Wms_StockDailyState '2012-05-20' exec P_Wms_StockDailyState '2012-05-21' exec P_Wms_StockDailyState '2012-05-22' exec P_Wms_StockDailyState '2012-05-23' exec P_Wms_StockDailyState '2012-05-24' exec P_Wms_StockDailyState '2012-05-25' exec P_Wms_StockDailyState '2012-05-26' exec P_Wms_StockDailyState '2012-05-27' exec P_Wms_StockDailyState '2012-05-28' exec P_Wms_StockDailyState '2012-05-29' exec P_Wms_StockDailyState '2012-05-30' exec P_Wms_StockDailyState '2012-05-31' exec P_Wms_StockDailyState '2012-06-01' exec P_Wms_StockDailyState '2012-06-02' exec P_Wms_StockDailyState '2012-06-03' exec P_Wms_StockDailyState '2012-06-04' exec P_Wms_StockDailyState '2012-06-05' exec P_Wms_StockDailyState '2012-06-06' exec P_Wms_StockDailyState '2012-06-07' exec P_Wms_StockDailyState '2012-06-08' exec P_Wms_StockDailyState '2012-06-09' exec P_Wms_StockDailyState '2012-06-10' exec P_Wms_StockDailyState '2012-06-11' exec P_Wms_StockDailyState '2012-06-12' exec P_Wms_StockDailyState '2012-06-13' exec P_Wms_StockDailyState '2012-06-14' exec P_Wms_StockDailyState '2012-06-15' exec P_Wms_StockDailyState '2012-06-16' exec P_Wms_StockDailyState '2012-06-17' exec P_Wms_StockDailyState '2012-06-18' exec P_Wms_StockDailyState '2012-06-19' exec P_Wms_StockDailyState '2012-06-20' exec P_Wms_StockDailyState '2012-06-21' exec P_Wms_StockDailyState '2012-06-22' exec P_Wms_StockDailyState '2012-06-23' exec P_Wms_StockDailyState '2012-06-24' exec P_Wms_StockDailyState '2012-06-25' exec P_Wms_StockDailyState '2012-06-26' exec P_Wms_StockDailyState '2012-06-27' exec P_Wms_StockDailyState '2012-06-28' exec P_Wms_StockDailyState '2012-06-29' exec P_Wms_StockDailyState '2012-06-30' exec P_Wms_StockDailyState '2012-07-01' exec P_Wms_StockDailyState '2012-07-02' exec P_Wms_StockDailyState '2012-07-03' exec P_Wms_StockDailyState '2012-07-04' exec P_Wms_StockDailyState '2012-07-05' exec P_Wms_StockDailyState '2012-07-06' exec P_Wms_StockDailyState '2012-07-07' exec P_Wms_S