1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| CREATE PROCEDURE PsGenereDatesExercice
AS
BEGIN
DECLARE @debutExercice DATETIME,
@finExercice DATETIME
SELECT @debutExercice = CAST(CAST(YEAR(GETDATE()) AS CHAR(4)) + '1001' AS DATETIME)
SELECT @finExercice = DATEADD(YEAR, 1, @debutExercice) - 1
;WITH
GENERE_DATES_EXERCICE (date, indice) AS
(
SELECT @debutExercice,
1 AS indice
UNION ALL
SELECT date + 1,
indice + 1
FROM GENERE_DATES_EXERCICE
WHERE date <= @finExercice
)
SELECT date
FROM GENERE_DATES_EXERCICE
OPTION (MAXRECURSION 366)
END |