I have a stored procedure with pseudocode like this:
ALTER PROCEDURE myProcedure(@param1 int, @param2 int, @returnCode int output)
AS
BEGIN
SELECT .... -- my query here
SET @returnCode = @@ROWCOUNT
END
However, when I execute this stored procedure, @returnCode is NULL:
DECLARE @returnCode INT
EXEC myProcedure 1, 1, @returnCode
SELECT @returnCode
Returns NULL.
However, if I just do a select within the proc rather than setting the return code - SELECT @@ROWCOUNT
- I get the correct row count.
How can I return this row count in the output param?
Append
OUTPUT
Keyword when executing the Procedure: