I have table like
Declare@Calendartable (FISC_YRint, FISC_MTHint)
;WITHCTE_FISYR(FY)
AS
(
SELECTFY=2005
UNIONALL
SELECTFY=FY+1FROMCTE_FISYR WHEREFY<2050
),
CTE_FISMON(FM)
AS
(
SELECTFM=1
UNIONALL
SELECTFM=FM+1FROMCTE_FISMON WHEREFM<12
)
,
CTE_GETDATA(FY,FM)
AS(
SELECT
[FISCAL_YEAR]=FY,
[FISCAL_MONTH]=FM
FROM[CTE_FISYR],[CTE_FISMON]
)
Insertinto@Calendar
Select*from CTE_GETDATA
--------------------------------
Select*from @Calendar
orderbyFISC_YR ,FISC_MTH
--------------------------------
from this table @Calendar, I want to get only those records where year-month >= today's year & month
expected output
2014 | 4 |
2014 | 5 |
2014 | 6 |
2014 | 7 |
2014 | 8 |
2014 | 9 |
2014 | 10 |
2014 | 11 |
2014 | 12 |
2015 | 1 |
2015 | 2 |
2015 | 3 |
2015 | 4 |
2015 | 5 |
2015 | 6 |
2015 | 7 |
2015 | 8 |
2015 | 9 |
2015 | 10 |
and so on.....
Please help to get the code...
Please Mark as Answer if my post solved your problem or Vote As Helpful if this helps. Blogs: www.sqlserver2005forum.blogspot.com