日期:2014-05-17 浏览次数:20466 次
DECLARE @s NVARCHAR(100)='201209'
,@e nvarchar(100)='201212'
SELECT LEFT(@s,4)+RIGHT('00'+CAST(a.number AS varchar(2)),2) FROM master..spt_values a
WHERE a.type='p' AND a.number BETWEEN CAST(RIGHT(@s,2) AS int) AND CAST(RIGHT(@e,2) AS int);
--------
201209
201210
201211
201212
--这个只支持同年的。