-
Contributing Member
How to declare variables in SP?
I am learning SQL server. When I am trying to learn stored procedure I have raised one queri that is How to declare variables in SP?
For example I have created on stored procedure as given below:-
CREATE procedure emp_DebugA
(
@IntIn int,
@IntOut int OUTPUT
)
as
Set @IntOut = @IntIn + 10
Return
and then I have typed command is
Declare @NewInt int
then I have typed command is
exec emp_DebugA 5,@NewInt OUTPUT - when I am executing this command it is showing errror msg like "Must declare the variable '@NewInt'."
-
Re: How to declare variables in SP?
please find the details of stored procedures here.
-
Junior Member
Re: How to declare variables in SP?
hi
stored procedore usually contains a set of SQl command to be executed.u try out with some SQL COMMANDS
U CAN excute a stored procedure as
declare @a int (all input variable)
set @a=5(giv input for all the varibles)
exec (all inpu variable & output variables.output variables should be hav output key word)
-
Junior Member
Re: How to declare variables in SP?
hi,
bharathi ur SP is perfectly right, i just copied and excuted in query analyser and it worked perfectly fine.. i hope after creating the SP :
***********
CREATE procedure emp_DebugA
(
@IntIn int,
@IntOut int OUTPUT
)
as
Set @IntOut = @IntIn + 10
Return
***********
and while exceuting the commnad below:
*************
Declare @NewInt int
exec emp_DebugA 5,@NewInt
*************
u have taken both the lines into account. if u havent then only it would give such an error.
-
Junior Member
Re: How to declare variables in SP?
Hi Bharati_ark,
The error is in the "exec" line of your coding.....
Execute the Stored Procedure as given below and try:
Declare @NewInt int
exec emp_DebugA 5 , @IntOut=@NewInt output
print @NewInt
Best Wishes
Sreedevi
Last edited by Sreedevi Pidaparthi; 10-01-2007 at 08:00 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules