过程或函数''期望参数''未提供

时间:2018-04-26 11:56:18

标签: sql sql-server sql-server-2008

请问如何解决这个问题。消息错误是:

  

过程或函数'ROHAN_GetPKList'需要参数'@char_id'未提供

我有SP

ALTER procedure [dbo].[ROHAN_GetPKList]
    @char_id    int
as      
set nocount on      
select top 100 k.pk_char_id,  c.[name], k.pk_char_type, k.pk_second, k.isKill, k.PKRecall, k.RecallRecharge, k.mode_type
    from TKill k, TCharacter c  
    where k.pk_char_id = c.[id] 
        and k.char_id = @char_id
        and c.[user_id] > 0
    order by k.[date]   

return @@error  

这是表'TKill'

    [char_id] [int] NOT NULL,
    [pk_char_id] [int] NOT NULL,
    [pk_char_type] [int] NOT NULL,
    [pk_second] [int] NOT NULL,
    [isKill] [tinyint] NOT NULL,
    [PKRecall] [tinyint] NOT NULL,
    [RecallRecharge] [tinyint] NOT NULL,
    [date] [smalldatetime] NOT NULL,
    [mode_type] [int] NOT NULL

这是表'TCharacter'

    [id] [int] IDENTITY(1000,1) NOT NULL,
    [name] [nvarchar](20) NULL,
    [ctype_id] [int] NOT NULL,
    [cface_id] [int] NOT NULL,
    [chair_id] [int] NOT NULL,
    [user_id] [int] NOT NULL,
    [mode] [tinyint] NOT NULL,
    [create_date] [datetime] NOT NULL,
    [flag] [tinyint] NOT NULL,
    [cstyle_type] [tinyint] NOT NULL,
    [cstyle_index] [tinyint] NOT NULL,
    [world_id] [tinyint] NOT NULL,
    [reward_time] [int] NOT NULL,
    [isSelling] [int] NULL,
    [pvppoint] [int] NULL,
    [pvppointoa] [int] NULL,

1 个答案:

答案 0 :(得分:0)

您的错误似乎是在程序调用时,而不是在定义时。但我建议将代码编写为:

alter procedure [dbo].[ROHAN_GetPKList] (
    @char_id    int  -- something called "char_id" with a type of "int" is strange
) as 
begin     
    set nocount on;  

    select top 100 k.pk_char_id, c.[name], k.pk_char_type, k.pk_second, k.isKill, k.PKRecall, k.RecallRecharge, k.mode_type
    from TKill k join
         TCharacter c  
         on k.pk_char_id = c.id
    where k.char_id = @char_id and c.user_id > 0
    order by k.[date]; 
    return @@error;
end;  -- ROHAN_GetPKList

请注意使用BEGIN / END和正确的JOIN语法。