Reputation: 6017
I have a stored procedure within SQL Server 2008. Inside this SP, I need to call another one and pass in two parameters as shown here: This gets executed at the end of the parent SP
EXEC [Testing].[InsertNewValues] @UserId, @RequestedById
This SP looks like this:
ALTER PROCEDURE [Testing].[InsertNewValues]
@UserId int,
@RequestedById int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Do something with two parameters
END
Yet when I run my project I get the error:
Additional information: Procedure or function 'InsertNewValues' expects parameter '@RequestedById', which was not supplied.
I've tried
EXEC [Testing].[InsertNewValues](@UserId, @RequestedById)
EXEC [Testing].[InsertNewValues] @UserId @RequestedById
EXEC [Testing].[InsertNewValues] (@UserId, @RequestedById)
But with no luck, can someone tell me what I'm doing wrong here?
Upvotes: 0
Views: 4069
Reputation: 2655
You can call any number of SP's from one SP (further you can extend this to other SP - nested). You can also call functions from your SP. But from your code, calling line and error.. All are indicating that you are not calling your SP properly and you are clearly missing parameter separator. This may be a typo.
You have missed a ,
between your parameters.
Change EXEC [Testing].[InsertNewValues] @UserId @RequestedById
to
EXEC [Testing].[InsertNewValues] @UserId, @RequestedById
Upvotes: 1
Reputation: 894
From
EXEC [Testing].[InsertNewValues](@UserId, @RequestedById)
EXEC [Testing].[InsertNewValues] @UserId @RequestedById
EXEC [Testing].[InsertNewValues] (@UserId, @RequestedById)
To
EXEC [Testing].[InsertNewValues] @UserId, @RequestedById
EXEC [Testing].[InsertNewValues] @UserId, @RequestedById -- missing comma here
EXEC [Testing].[InsertNewValues] @UserId, @RequestedById
please try, I think I may not need to know why its 3 times..my assumptions is you might be testing your validation with duplicates.
Upvotes: 0