我有一个调用存储过程的报告。proc 声明了 3 个参数,但我在运行时收到错误“程序没有参数并且提供了参数”。我不确定还能做什么。
ALTER PROCEDURE [dbo].[uspFirstCurveProcess] AS
DECLARE @Period int
DECLARE @Year varchar(4)
DECLARE @FacilityID int;
/* SET @period = 4
SET @FacilityID = 3101
SET @Year = 2013; */
WITH Process_cte AS (
SELECT [FacilityID]
,[FiscalYear]
-- ,[MonthNumber]
,[Measure]
,[SubAccount]
,SUM([MthAmt]) AS MthAmt
,SUM([BudgAmt]) AS BudgAmt
,0 AS [YTDAmt]
FROM EVAL.dbo.FirstCurveProcess
WHERE FacilityID = @FacilityID
AND MonthNumber = @Period
AND FiscalYear = @Year
GROUP BY FacilityID,FiscalYear,Measure,Subaccount
UNION
SELECT [FacilityID]
,[FiscalYear]
-- ,[MonthNumber]
,[Measure]
,[SubAccount]
,0 AS [MthAmt]
,0 AS [BudgAmt]
,SUM(MthAmt) AS [YTDAmt]
FROM EVAL.dbo.FirstCurveProcess
WHERE FacilityID = @FacilityID
AND MonthNumber <= @Period
AND FiscalYear = @Year
GROUP BY FacilityID,FiscalYear,Measure,SubAccount --MonthNumber,
)
SELECT [FacilityID]
,[FiscalYear]
-- ,[MonthNumber]
,[Measure]
,[SubAccount]
,SUM([MthAmt]) AS MthAmt
,SUM([BudgAmt]) AS BudgAmt
,SUM(YTDAmt) AS [YTDAmt] FROM Process_cte
GROUP BY FacilityID,FiscalYear,Measure,Subaccount