日期:2014-05-18 浏览次数:20861 次
select * into #workTable from (
select 1 as id ,'张三' as work_name,'2012-06-18' as work_date,'test' as work_content, 0 as status
union
select 2,'张三','2012-06-22','test2',0
union
select 3,'张三','2012-06-26','test4',0
union
select 4,'张三','2012-06-28','test4',0
union
select 5,'张三','2012-06-30','test4',0) a
while exists(select 1 from #workTable where dateadd(day,1,work_date) not in (select work_date from #workTable)
and ID <> (select MAX(id) from #workTable))
begin
insert into #workTable
select id,'',convert(varchar(10),dateadd(day,1,work_date),120),'',0
from #workTable
where dateadd(day,1,work_date) not in (select work_date from #workTable)
and ID <> (select MAX(id) from #workTable)
end
select * from #workTable order by ID,work_date