日期:2014-05-17 浏览次数:20632 次
declare @start datetime,@end datetime,@index int
if OBJECT_ID('#t') is not null
drop table #t
create table #t
(
[date] datetime
)
set @start='2013-05-20';
set @end='2013-05-23';
set @index=0;
while DATEADD(day,@index,@start)<=@end
begin
insert into #t values(DATEADD(day,@index,@start));
set @index=@index+1;
end
select t1.date,case when t2.value is null then 0 else t2.value end value
from
#t t1 left join #table t2
on t1.date=t2.date