Prześlij pliki do ''

Skrypt generowania kalendarza hurtowni
This commit is contained in:
Bartosz Kozłowski 2017-04-19 09:20:12 +00:00
parent 7369b9fec1
commit 0935e7e0cd

24
Kalendarz.sql Normal file
View File

@ -0,0 +1,24 @@
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;