2

我有一个调用存储过程的报告。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
4

2 回答 2

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

我想你在过程中声明了参数

于 2013-07-25T16:47:17.230 回答
0

尝试从您作为注释的行中删除“/*”和“--”。这些可能是它抱怨的台词。这些行不会被执行,并且您使用这些参数包含了参数。

于 2014-11-20T11:45:37.470 回答