简体   繁体   English

SQL Server-存储过程

[英]SQL Server - stored procedure

I am trying to create a stored procedure in SQL Server 2008. According to the parser, the syntax is OK. 我正在尝试在SQL Server 2008中创建存储过程。根据解析器,语法是可以的。 However, when I try to execute the stored procedure and pass actual values, the following error comes up: 但是,当我尝试执行存储过程并传递实际值时,出现以下错误:

Msg 201, Level 16, State 4, Procedure SaveOneTimeDonation, Line 0 消息201,级别16,状态4,过程SaveOneTimeDonation,第0行
Procedure or function 'SaveOneTimeDonation' expects parameter '@donation', which was not supplied. 过程或功能“ SaveOneTimeDonation”需要未提供的参数“ @donation”。

Strange enough, the data is actually inserted into the table so I don't know why it is displaying this error. 奇怪的是,数据实际上已插入表中,所以我不知道为什么它显示此错误。

How can I solve this problem please? 请问该如何解决? Here is the code: 这是代码:

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

ALTER PROC [dbo].[SaveOneTimeDonation]
  @donation float,
  @date nvarchar
AS
   INSERT INTO OneTime_Trans(Donation, Trans_Date) VALUES (@donation, @date)

   exec SaveOneTimeDonation

The last line is executing the stored procedure. 最后一行正在执行存储过程。 There it is missing the parameters. 那里缺少参数。

exec SaveOneTimeDonation

Good luck! 祝好运!

存储过程带有参数,因此在最后尝试执行存储过程时,应提供参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM