You are here: Re: How to get a SP return value on another SP? « MsSQL Server « IT news, forums, messages
Re: How to get a SP return value on another SP?

Posted by Cylix on 09/12/06 08:01

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация