Reputation: 53
I get the exception
"The formal parameter "@param1" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output"
I'm pretty sure I got everything in the correct order.
Is anything wrong with this stored procedure?
CREATE PROCEDURE spHello
@param1 INT,
@param2 INT OUT
AS
BEGIN
SET @param2 = @param1 + 2
RETURN 1
END
I call it using this:
DECLARE @return_value int, @param2out int
EXEC @return_value = spHello 1, @param2out OUTPUT
SELECT @param2out as N'@param2'
SELECT 'Return Value' = @return_value
Upvotes: 2
Views: 3615
Reputation: 175924
Your code looks correct: Demo.
I guess the problem is with parameter list order. To avoid confusion I would use named parameters:
DECLARE @return_value int, @param2out int;
EXEC @return_value = spHello @param1 = 1, @param2 = @param2out OUTPUT;
SELECT @param2out AS [@param2],
@return_value AS [Return Value];
It's a good practice to end each statement with semicolon.
Upvotes: 4