0

I try to make a query and it works well, but when i put it in a stored procedure.I can't figure out whats wrong with my code. It says
Procedure or function has too many arguments specified

Stored procedure code

******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[uspEnrolledStudents]
    -- Add the parameters for the stored procedure here
@SchoolYear Nvarchar(20),
@levels Nvarchar(20),
@Section Nvarchar(20),
@DateEnrolled Date

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;     
            DECLARE @studID INT


    INSERT INTO StudentHistory(SchoolYear,Levels,Section,DateEnrolled,StudentID) 
        VALUES(@SchoolYear,@levels,@Section,@DateEnrolled,@studID)

END

I Execute it with this code:

EXEC dbo.uspEnrolledStudents '2016-2017','GRADE 11','SAINT RAMON','2015-1-2','380'
2
Contributors
1
Reply
19
Views
1 Year
Discussion Span
Last Post by rubberman
0

You are passing 5 arguments instead of the 4 that the procedure is defined to use. It looks like the 5th argument is the @studID you are declaring later in the procedure. Why not place that in the argument list?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.