I have a stored procedure that I am trying to test. I am trying to test it through SQL Management Studio. In order to run this test I enter ...
exec my_stored_procedure 'param1Value', 'param2Value'
The final parameter is an output parameter
. However, I do not know how to test a stored procedure with output parameters.
How do I run a stored procedure with an output parameter?
Here is the stored procedure
And here is the way to execute the procedure
From http://support.microsoft.com/kb/262499
Example:
Hope this helps!
First, declare the output variable:
Then, execute the stored procedure, and you can do it without parameter's names, like this:
or with parameter's names:
And finally, you can see the output result by doing a
SELECT
:Please check below example to get output variable value by executing a stored procedure.
you can do this :
How about this? It's extremely simplified:
The SPROC below has an output parameter of
@ParentProductID
We want to select the value of the output of
@ParentProductID
into@MyParentProductID
which is declared below.Here's the Code: