我有一个调用存储过程的报告。 proc有3个参数已声明,但我在运行时收到错误“Procedure没有提供参数和参数”。我不确定还能做什么。
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
答案 0 :(得分:4)
请检查此格式
GO
IF OBJECT_ID(N'[dbo].[uspFirstCurveProcess]',N'P') IS NOT NULL
DROP PROCEDURE [dbo].[uspFirstCurveProcess]
GO
CREATE PROCEDURE [dbo].[uspFirstCurveProcess]
(
@Period int
,@Year varchar(4)
,@FacilityID int
)
as
begin
//your code
end
我认为你在程序中声明了参数
答案 1 :(得分:0)
尝试删除&#34; / *&#34;和&#34; - &#34;从你作为评论的那些行。这些可能就是它所抱怨的。这些行不会被执行,你使用这些参数包含了参数。