sdc248
asked on
how to supress the returned data row from a stored procedure
Hi:
I am calling a stored procedure, which returns an int, let's call it sp1, from another stored procedure, sp2. I need to store the returned value from sp1 in a variable but I don't want that returned value to be part of the returned data row of sp2. Any way I can pull this off?
Currently the following gives me two returned data set and I do not want the first one:
-- in sp2:
...
DECLARE @myvariable int
EXEC @myvariable= spMyStoredProcedure 'arg1', 'arg2' --sp1, it returns one int
select @myvariable
...
Thanks.
I am calling a stored procedure, which returns an int, let's call it sp1, from another stored procedure, sp2. I need to store the returned value from sp1 in a variable but I don't want that returned value to be part of the returned data row of sp2. Any way I can pull this off?
Currently the following gives me two returned data set and I do not want the first one:
-- in sp2:
...
DECLARE @myvariable int
EXEC @myvariable= spMyStoredProcedure 'arg1', 'arg2' --sp1, it returns one int
select @myvariable
...
Thanks.
ASKER
Looks like my problem is that the return value from sp1 (sp_test1 in your example) was actually from a SELECT statement instead of a RETURN statement. That is, if I change the last statement in sp_test1 to be "select @t", I'd get '5' as a data row followed by a '0' as a 2nd data row from sp_test2.
Anything I can do in sp_test2 to resolve the issue without changing sp_test1?
Anything I can do in sp_test2 to resolve the issue without changing sp_test1?
so, what you want the end result to be...
You want to read the 5 and leave the zero??? a bit confused here.
You want to read the 5 and leave the zero??? a bit confused here.
ASKER
Assuming the last statement in sp_test1 was "select @t", I want sp_test2 to return 5 and only 5.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The 2nd scenario works for me. Thanks.
Check this out
Open in new window