25 lines
692 B
Transact-SQL
25 lines
692 B
Transact-SQL
|
|
declare @StartDate date;
|
|
declare @EndDate date;
|
|
declare @DateCounter int;
|
|
set @StartDate = '1900-01-01'; -- min wartość daty w Claim 1900/01/01
|
|
set @EndDate = '2207-12-31'; -- max wartośc daty w Claim 2207/12/25
|
|
set @DateCounter=1;
|
|
|
|
declare @TempDate date;
|
|
set @TempDate=@StartDate;
|
|
|
|
While @TempDate<=@EndDate
|
|
Begin
|
|
INSERT into Calendar ([Date], [Year],[Month],[Day],[Qarter])
|
|
values (
|
|
@TempDate,
|
|
cast( DATENAME(yyyy, @TempDate) as varchar(4)),
|
|
cast( DATEPart(mm, @TempDate) as varchar(2)),
|
|
cast( DATEPart(dd, @TempDate) as varchar(2)),
|
|
cast( DATENAME(q, @TempDate) as varchar(2))
|
|
);
|
|
set @TempDate=DATEADD(d , @DateCounter, @TempDate);
|
|
End;
|
|
|