select t1.[Account Number],
dateadd(m, t2.number, 0) as tdate
into #tem
from (
select [Account Number],
datediff(m, 0, [Transaction Date]) as tdate,
datediff(m, 0, getdate()) as mdate
from yourtable a
where [Transaction Date] = (select min([Transaction Date]) from yourtable where [Account Number] = a.[Account Number])
) t1
cross join (select number from enum_table) t2
where t2.number between t1.tdate and t1.mdate
|