0

I currently have a stored procedure I'm working on that's supposed to output a message when something fails.

ALTER PROCEDURE---
@in_id INT
@msg NVARCHAR(30) = OUTPUT

The procedure variables are structured like this where one of them is an input parameter and the msg is an output.

The idea is that it uses that input parameter of an ID which works as an identification that changes the message based on the ID so the end of the sproc looks something like:

SET @msg = usf_change_message(@id, @msg)

I get an error stating that the sproc is trying to treat @msg as an input variable when in actuality it's an OUTPUT param? Can someone help me with this issue?

1 Answer 1

1

You use your SP as function which is obviously wrong - SP does not return a value.

You must use:

CALL usf_change_message(@id, @msg);
SELECT @msg;

Or you may convert SP to UDF and use your SELECT query (but in this case @msg in UDF parameters is excess and should be removed).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.