December 12, 2006 at 2:34 pm
I want to return a value (from a procedure) to it's calling procedure for error processing. Much like a function does set @Value = dbo.function.
Create Proc...
as
Exec s_Proc
IF return value = 1
Print 'Error'
Not sure if I can set the output of a proc to a variable in the calling procedure. Any suggestions?
December 12, 2006 at 2:39 pm
Yes. Use this syntax
DECLARE @return_Val INT EXEC @return_Val = s_Proc IF @return_val =...
This will work as long as the proc uses the RETURN statement.
SQL guy and Houston Magician
December 12, 2006 at 2:39 pm
exec @return = Proc arg1, ...
December 12, 2006 at 3:28 pm
Use the return statement in your procedure to return an Integer value.
i.e.
Create proc ReturnTest
as
declare @E int
select 1/0
set @E = @@error
If @E <> 0
begin
print 'Error encountered'
return @E
end
December 13, 2006 at 8:32 am
Thanks everyone for the suggestions and quick replies. I didn't think it was that simple.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply