DECLARE @Start_Date VARCHAR(10)
DECLARE @End_Date VARCHAR(10)
DECLARE @i INT
SET @Start_Date='2012-01-01'
SET @End_Date='2013-03-01'
SET @i=1
create table #T_CountDate (
T_Date VARCHAR(10)
)
WHILE CONVERT(VARCHAR(7),
dateadd(m,@i,@Start_Date),120)<=CONVERT(VARCHAR(7),@End_Date,120)
BEGIN
--SELECT CONVERT(VARCHAR(7),DATEADD(m,@i,@Start_Date),120)
INSERT #T_CountDate
( T_Date )
VALUES ( CONVERT(VARCHAR(10),DATEADD(m,@i,@Start_Date),120)
)
SET @i=@i+1
END
SELECT * FROM #T_CountDate
--数据处理过程
--BEGIN
--END
--数据处理结束
DROP TABLE #T_CountDate