Solved

SQL Msg 8162, Level 16, State 2

Posted on 2014-02-19
6
1,078 Views
Last Modified: 2014-02-19
When I execute the SQL procedure I get the following error message...

Msg 8162, Level 16, State 2, Procedure spITS_FullCaseLabels, Line 0
Formal parameter '@iUserID' was defined as OUTPUT but the actual parameter not declared OUTPUT.

Please see the attached jpg file for a screen shot and more information.
Thanks in advance.
msg-8162.JPG
0
Comment
Question by:tesla764
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Assisted Solution

by:PadawanDBA
PadawanDBA earned 275 total points
ID: 39870437
Doesn't appear that the sp has the iUserID parameter defined as an output parameter in the proc definition.  You'll need to alter the procedure to mark that as an output parameter.
0
 

Author Comment

by:tesla764
ID: 39870454
Could you tell me how to do that?
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 225 total points
ID: 39870464
please remove the OUTPUT for all the parameters excel the result and result_code parameters.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Accepted Solution

by:
PadawanDBA earned 275 total points
ID: 39870483
Sure thing!  Easiest way:  right click the stored procedure > script stored procedure as > alter to > new query window.  Then all you'll need to do is look for the "@iUserID bigint" and change that to "@iUserID bigint OUTPUT".


Edit:
Guy does bring up a good point.  Unless your stored procedure is doing something that assigns a value to the @iUserID variable, it's not really going to do anything.
0
 

Author Comment

by:tesla764
ID: 39870494
Do you mean in the EXEC area remove all the OUTPUT statements?
What do you mean by...
excel the result and result_code parameters
Could you please explain.
I have never encountered this situation before.
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 225 total points
ID: 39870611
you have the code like this :
declare @variable_1 data_type
 , @variable_2 data_type
 ...etc...
exec procedure_name @variable_1 OUTPUT
   ,  @variable_2 OUTPUT
    ... etc  ...

select @variable_1
    , @variable_2 
  ... etc ...

Open in new window


now, the BIG question is: should the stored procedure return data into all those (output) parameters or not.

if yes: the parameter code is wrong, as only the first 2 parameters (in the procedure itself, not in the calling code) are defined to be OUTPUT. to change that, you have to EDIT the stored procedure, and add OUTPUT to the parameter declaration. when you have the code of the stored procedure opened, you shall see that easily

if not: remove the OUTPUT keyword for all the parameters in the EXEC procedure_name part which are NOT returning any value, but for which you have to provide some input data so the procedure knows on what to work on.
for those, you need to SET the data, which needs to happen between the DECLARE and the EXEC part, like this:
set @variable = some_value

if all of this is "chinese" to you, I think you are completely wrong person on the task you are trying to achieve, in the sense that unless you do some SQL (T-SQL) training, you should keep your hands from the keyboard
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question