Thank you.
Actually, my case is a bit more complicated.
It is because, which SP is going to exec is also depends on input,
and so, in my SP, I need to
DECLARE @SQL as VARCHAR,
SET @SQL = 'exec ' + @THE_SP + ' ' + @PARM1
EXEC (@SQL)
In this structure, Can I still get the return value?
If not, any suggection?
Erland Sommarskog wrote:
You could use an OUTPUT parameter for this.
CREATE PROCEDURE inner_sp @x int OUTPUT AS
SELECT @x = 23
go
CREATE PROCEDURE outer_sp AS
DECLARE @x int
EXEC inner_sp @x OUTPUT
PRINT '@x is ' + ltrim(str(@x))
The trick is that you must specify OUTPUT when you call the procedure as
well.