General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Passing arguments by reference
I'm trying to call a SP (from another SP) with arguments that needs to be modified by the called SP.
I could not find references on passing arguments by reference, so I tried with the OUTPUT argument modifier. Here is a simple example to explain my approach.
USP_O_MYPROC @ORIGINAL_VALUE INT, @NEW_VALUE INT OUTPUT
...
...
SET @NEW_VALUE = @ORIGINAL_VALUE + 1 !!! complex ;-)
IF @NEW_VALUE IS NULL SET @NEW_VALUE = 0 !!! you'll see why later...
RETURN
When I call the SP, I simply do:
EXEC USP_O_MYPROC @tata, @tata
I tough that by doing so, @tata whould containt it's original value + 1...
But @tata is null !!!! I'm puzzled ;-)
The IF @NEW_VALUE IS NULL SET @NEW_VALUE = 0 line does not even change a thing...
So what am I doing wrong here ;-)
Thanks.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only