SQL获取时间段内的所有月份

select convert(varchar(7),dateadd(month,number,'2010-01-01'),120) AS MONTH
from master..spt_values
where type='P' and dateadd(month,number,'2010-01-01')<='2010-09-01'

你可能感兴趣的:(SQL获取时间段内的所有月份)