Proc output parameter

I have a Q/A but I am not sure if the answer is correct.

Question:
 How can you use output parameters in T-SQL stored procedures? (Choose all that apply.)
A. You can pass data into a procedure by using an output parameter, but you cannot receive information back from it.
B. You can pass data into a procedure by using an output parameter, and any change made to the parameter will be passed back to the calling routine.
C. You cannot pass data into a procedure by using an output parameter; it is only used for passing data back to the caller.
D. You cannot pass data into a procedure by using an output parameter, nor can you receive data back from a procedure from an output parameter.

Answer :
A. Incorrect: You can use an output parameter to receive information back from a stored procedure.
B. Correct: You can both pass data into a stored procedure and retrieve information back from it, by using an output parameter.
C. Incorrect: An output parameter is not used only for passing data back to the caller of the stored procedure. It is also used to pass data from the caller to a stored procedure.
D. Incorrect: You can both pass data into a stored procedure and retrieve information back from it, by using an output parameter.

My Question:  We get data back via output parameter, can we also pass data to a proc using output parameter as the answer above suggests?

It seems to me this study guide (a book) has it wrong and the correct answer should be:
A. You can use an output parameter to receive information back from a stored procedure.

in my test proc below, I am not able to assign any value to @oo to pass it to @o:
DROP PROC Sales.ListSampleResultsSets;
GO
CREATE PROC Sales.ListSampleResultsSets
@A int
, @o int output
AS
BEGIN
select @a;
select @o;
set @o =8;
End
GO
declare @oo int --= 3 int
EXEC Sales.ListSampleResultsSets 1 , @oo output
Select @oo

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Sure you can. If you're using SQL Server 2005 or older just make sure you split the declaration and assignment of the variable:
declare @oo int
set @oo = 3

Open in new window

From SQL Server 2008 (only tested in 2012) it's possible to use assignments in the declaration:
declare @oo int = 3

Open in new window

So 'output' does in fact create an input/output parameter.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi Robert,

Thank you for the response. I had a dumm mistake with

declare @oo int= 3; was trying declare @oo = 3 int;

BTW, I am catching up with you soon in points. LOL

Mike
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.