我有一个数据类型问题。以下代码行适用于我们的数据库:
WHERE e_ru IN (5420,5410,5550,6230,6240,6250)
现在我想e_ru
为每个月插入一组不同的数字。
DECLARE @StartDate DATETIME, @EndDate DATETIME, @MonthOfYear TINYINT, @RUsToAudit NVARCHAR
SET @StartDate = (dateadd(month, datediff(month, 0, DATEADD(month, -6, GETDATE())),0)+15)
SET @EndDate = (dateadd(month, datediff(month, 0, DATEADD(month, 0, GETDATE())),0)+14)
SET @MonthOfYear = DATEPART(month, GETDATE())
SET @RUsToAudit =
CASE
WHEN @MonthOfYear = 1 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 2 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 3 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 4 THEN (SELECT 5460,5470,5500)
WHEN @MonthOfYear = 5 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 6 THEN (SELECT 5530,5910)
WHEN @MonthOfYear = 7 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 8 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 9 THEN (SELECT 5460,5470,5500)
WHEN @MonthOfYear = 10 THEN (SELECT 5420,5410,5550,6230,6240,6250)
WHEN @MonthOfYear = 11 THEN (SELECT 5530,5910)
WHEN @MonthOfYear = 12 THEN (SELECT 5420,5410,5550,6230,6240,6250)
END
SELECT @StartDate AS 'Report Start Date', @EndDate AS 'Report End Date', @MonthOfYear AS 'Month', @RUsToAudit AS 'Programs'