語意:
假如有幾筆(Row)資料N,而每S天要變成一筆(Row)資料,最長增加到X天
假如有2Row資料,而每3天要變成一筆Row,最多增加60天
select x.id,x.val,x.seq,ret.number,dateadd(day,ret.number,x.dday) as v_date from ( select 'row1' as id,'myvalue1' as val,222 as seq , CONVERT(datetime,'2014/06/06' ) as dday union all select 'row2' as id,'myvalue2' as val,111 as seq , CONVERT(datetime,'2014/06/03') as dday )x ,(select n.number from master..spt_values n where n.type = 'P' AND n.number < 60 and n.number <>0 and n.number % 3 =0)ret order by x.seq,v_date
2筆資料