我想在SQL Server中创建一个函数
我创建了一个临时表但是我想在sqlserver中为下面的代码
创建函数DECLARE @StartDate DATETIME
,@EndDate DATETIME;
SELECT
@StartDate ='20100101',
@EndDate = GETDATE()
--convert(varchar(8), GETDATE(),112);
;With DT_TempTbl as
(
SELECT
@StartDate AS YearMonth
UNION ALL
SELECT
DATEADD(MONTH, 1, YearMonth)
FROM
DT_TempTbl
WHERE
YearMonth <= @EndDate
)
SELECT
CONVERT(VARCHAR(6), YearMonth, 112) AS YearMonth1
FROM
DT_TempTbl
ORDER BY
YearMonth1
请帮我在sqlserver中创建函数