插入半小时的中间表
作者:互联网
DECLARE @Count INT
SELECT @Count= COUNT(1) FROM DZ_TEMP.dbo.Temp_Five_Time_Interval_Source
BEGIN
IF @Count>0
TRUNCATE TABLE DZ_TEMP.dbo.Temp_Five_Time_Interval_Source
END
--插入数据
DECLARE @dayBegin datetime,@dayEnd datetime
set @dayBegin = '2020-07-25 00:00'
set @dayEnd = '2020-07-25 23:59'
while @dayBegin <=@dayEnd
begin
insert INTO DZ_TEMP.dbo.Temp_Five_Time_Interval_Source
select @dayBegin dayBegin ,dateadd(mi,30,@dayBegin) dayEnd --每30分钟一个间隔
SET @dayBegin=dateadd(mi,30,@dayBegin)
END
标签:半小时,dbo,中间,TEMP,插入,DZ,Temp,Five,dayBegin 来源: https://www.cnblogs.com/CloudHaiYun/p/15012802.html