Matthew
Matthew

Reputation: 4607

SQL Server - stored procedure

I am trying to create a stored procedure in SQL Server 2008. According to the parser, the syntax is OK. 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
Procedure or function 'SaveOneTimeDonation' expects parameter '@donation', which was not supplied.

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

Upvotes: 0

Views: 645

Answers (2)

EkremG
EkremG

Reputation: 131

Stored procedure is with parameters so at the end you should give parameters when you try to execute it.

Upvotes: 1

E.F. Nijboer
E.F. Nijboer

Reputation: 176

The last line is executing the stored procedure. There it is missing the parameters.

exec SaveOneTimeDonation

Good luck!

Upvotes: 2

Related Questions