declare @start date,@end date; set @start='2010-01-01'; set @end='2010-02-01'; --获取时间段内日期列表 select [day]=dateadd(day, number - 1, @start) from master.dbo.spt_values where type='P' and number <= datediff(day, @start,@end) + 1 and number>0…
select convert(varchar(7),dateadd(month,number,'2010-01-01'),120) AS MONTHfrom master..spt_valueswhere type='P' and dateadd(month,number,'2010-01-01')<='2010-09-01'…
,'2015-01-01 00:00:00') h INTO vinson_h DELETE vinson_h DECLARE @h int SELECT @h=DATEDIFF(HOUR,'2015-01-01 00:00:00',GETDATE()) WHILE(@num<=@h) BEGIN INSERT INTO vinson_h(h) values (DATEADD(HOUR,@num,'2015-01-01 00:00:00')) END SELECT * FROM vinson_h…