truncate table DimContact.DimTime;
declare @dtstart datetime;
select @dtstart=max(DimDate) from DimContact.DimTime;
select @dtstart=coalesce(@dtstart,getdate()-50000);
while @dtstart<getdate()+5000
begin
INSERT INTO DimContact.DimTime(DimDate
,DateYear
,DateQuarter
,DateMonth
,DateWeek
,DateDay
,DateHour
,DateWeekDay)
select
@dtstart,
Year(@dtstart),
DATEPART(quarter, @dtstart),
Month(@dtstart),
DATEPART(Week,@dtstart),
Day(@dtstart),
DATEPART(HOUR,@dtstart),
DATEPART(WEEKDAY,@dtstart);
PRINT 'data '+CAST(@dtstart AS VARCHAR);
select @dtstart=DATEADD(HOUR,1,@dtstart);
end;
Can you share your idea for a Time dimension?
Nenhum comentário:
Postar um comentário
thank you!