(记录)MSSQL 的一些应用--- 查询数据统计适用 添加月份日号作为行记录
declare @i int
declare @tab table(dayNo int)
declare @DC int
set @DC = datediff(day,'2009-02-01',dateadd(month,1,'2009-02-01'))
set @i = 0
while(@i < @DC) begin
set @i=@i+1
insert into @tab values (@i)
end
select * from @tab
declare @tab table(dayNo int)
declare @DC int
set @DC = datediff(day,'2009-02-01',dateadd(month,1,'2009-02-01'))
set @i = 0
while(@i < @DC) begin
set @i=@i+1
insert into @tab values (@i)
end
select * from @tab
生成效果贴图