我目前正在尝试将此查询放入 Visual Studio
DECLARE @StartDate date
SELECT @StartDate = GETDATE();
WITH cte AS
(
SELECT -1 AS idx, DATEADD(d,-1,@StartDate) AS idxDate
UNION ALL
SELECT idx -1, DATEADD(d,-1,idxDate)
FROM cte
WHERE idx >-365
)
SELECT idx DateValue, CONVERT(VARCHAR (11),idxDate,109) + ', ' + CAST
(idx as nvarchar(max)) DateLabel
FROM CTE
OPTION (MAXRECURSION 0)
但是我得到这个错误说
nvarchar is invalid for argument 2 of dateadd function
这里有什么问题吗?