你能帮我硬编码到 CalendarMonth 排序下面的 T-SQL SELECT 语句中,这样当有人查询它出来的数据时,它是一月、二月而不是四月、八月。我已经为 FinancialMonth 行做了这个,但在 CalendarMonth 上遇到了困难。
BEGIN
INSERT INTO Time3(Date,CalendarYear,CalendarMonth,FinancialYear,FinancialMonth)
SELECT
@StartDate Date,YEAR(@StartDate) AS CalendarYear,
DATENAME(MONTH,@StartDate) AS CalendarMonth,
YEAR(Dateadd(MONTH,-3,@StartDate)) AS FinancialYear,
'Period ' + RIGHT('0' + CAST(MONTH(Dateadd(MONTH, -3,@StartDate)) AS VARCHAR(2)),2) AS FinancialMonth
SET @StartDate = DATEADD(dd,1,@StartDate)
END