我想在下面的代码中使用dateadd函数时使用IN @Parameter
declare @interval int
--set @interval
SELECT ROW_NUMBER() OVER (ORDER BY datetime) AS Row,
RIGHT(LEFT(E.Name, 11), 8) AS Device, P.[DateTime],
day(p.DateTime) AS Day,
month(p.DateTime) AS Month,
P.AverageValue, p.StandardDeviation
FROM [dbo].[vManagedEntity] AS E
INNER JOIN [Perf].[vPerfDaily] AS P ON E.ManagedEntityRowId = P.ManagedEntityRowId
INNER JOIN [dbo].[vPerformanceRuleInstance] AS I ON
P.PerformanceRuleInstanceRowId = I.PerformanceRuleInstanceRowId
INNER JOIN [dbo].[vPerformanceRule] AS R ON R.RuleRowId = I.RuleRowId
WHERE right(left(e.name,6),3) IN (@Site)
AND R.CounterName = 'MPLS Utilization % (Average)'
AND p.DateTime >= DATEADD(MM, (@interval), GetUTCDate())
我想使用
p.DateTime >= DATEADD(MM, IN (@interval), GetUTCDate())
但它不允许它。