Thanks, Jeff
I just started to go into CROSS APPLY, being a JOIN person I'm trying to translate in into join, and still can't make it work as in original CROSS APPLY, join can't recognize n, I think it's the main difference/advantage for APPLY.
d
--*CROSS APPLY (SELECT n FROM Tally WHERE n BETWEEN 1 AND period+1) c
inner join #Tally on N between 1 and Period+1
--* CROSS APPLY (SELECT [month]=DATEPART(month, a.fromDD+n-1),DD=CAST(a.fromDD+n-1 AS DATE))
inner join (SELECT [month]=DATEPART(month, a.fromDD+n-1),DD=CAST(a.fromDD+n-1 AS DATE)) z
on 1 = 1
Tx
M