Solved

SQL Msg 8162, Level 16, State 2

Posted on 2014-02-19
6
1,164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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 143

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

695 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