declare @stime datetime; declare @etime datetime set @stime ='2015-01-01' set @etime='2015-02-01' insert into send_SMS_Log (Tdatetime) select @stime while @stime<DATEADD(DAY,-1,@etime) begin insert into send_SMS_Log (Tdatetime) select DATEADD(DAY,1,@stime) set @stime=DATEADD(DAY,1,@stime) end