SQLServer一条SQL查出当月的每一天
select number+1 from master..spt_values where type='p'
and DATEADD(day,number, cast(CONVERT(varchar(7),'2013-02-03')+'-01' as datetime))<DATEADD(MONTH,1,cast(CONVERT(varchar(7),'2013-02-03')+'-01' as datetime))

select CAST( CONVERT(varchar(7),'2013-02-03')+'-'+CONVERT(VARCHAR(2),number+1) AS datetime) from master..spt_values where type='p'
and DATEADD(day,number, cast(CONVERT(varchar(7),'2013-02-03')+'-01' as datetime))<DATEADD(MONTH,1,cast(CONVERT(varchar(7),'2013-02-03')+'-01' as datetime))

原文地址:https://www.cnblogs.com/gates/p/5630532.html

浙公网安备 33010602011771号