MS SQL Server — генерация года и месяца в SQL-query

Случай, когда нужно сгенерировать год и месяц, используя только SQL-query:

SELECT SS.YYYY, TT.MM FROM
(SELECT 10*10*(a-1) + 10*(b-1) + (c-1) + 2000 AS YYYY FROM
(SELECT 1 a UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) x
CROSS JOIN
(SELECT 1 b UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) y
CROSS JOIN
(SELECT 1 c UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) z
WHERE 10*10*(a-1) + 10*(b-1) + (c-1) <= (YEAR(GETDATE()) - 2000)) SS
,
(SELECT 10*10*(a-1) + 10*(b-1) + c AS MM FROM
(SELECT 1 a UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) x
CROSS JOIN
(SELECT 1 b UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) y
CROSS JOIN
(SELECT 1 c UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10) z
WHERE 10*10*(a-1) + 10*(b-1) + c <= 12) TT
ORDER BY SS.YYYY, TT.MM

YYYY  MM
.....      ....
2013    10
2013    11
2013    12
2014    1
2014    2
2014    3
2014    4
2014    5
2014    6
2014    7
2014    8
2014    9
2014    10
2014    11
2014    12
Реклама

Visual FoxPro 9 Disable check Internet connection when you start

1. Open Visual FoxPro 9.
2. Select Tools -> Task Pane on the toolbar.
VFP9_Tools_TaskPane
3. In window Task Pane Manager click Options.
VFP9_Tools_TaskPane_Options
4. In window Task Pane Options go to the section Start and put checkmark of NeverThis prevents the check connection to Internet during the start of the program.
VFP9_Tools_TaskPaneOptions_Start
5. If necessary, you can disable check of Internet access in another sections: Task Pane Manager, Community, Solution Samples, XML Web Services.