Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calling as SP From Withing a SP

Author  Topic 

Nick
Posting Yak Master

155 Posts

Posted - 2001-12-04 : 14:47:34
Hi-

What is the syntax to call as SP from within another SP. The SP I'm calling has 3 inputs an 1 output values. I would like to get the value of the outputted value.

I'm assuming I use exec spName a, b, c, d -- but how do I get the new value of d?

Thanks!

shankarc
Starting Member

37 Posts

Posted - 2001-12-04 : 14:53:36
declare @d datatype

exec spName @a,@b,@c,@d out (this indicates that d is an output parameter)

After execution the value is @d can be retrieved using Select.

Go to Top of Page

Nick
Posting Yak Master

155 Posts

Posted - 2001-12-04 : 14:55:42
Thank you. Will I need to retreive @d by using a select, or can I just use @d from that point on as the new value?

quote:

declare @d datatype

exec spName @a,@b,@c,@d out (this indicates that d is an output parameter)

After execution the value is @d can be retrieved using Select.



Go to Top of Page

katnthebag
Starting Member

3 Posts

Posted - 2001-12-06 : 13:35:15
Nick,

From the way described above, @d will contain the result from 'spName'. You can then use it as you would any other delcared variable in a stored procedure. The only reason I could see you wanting to 'SELECT @d' is to return it as a query result from your sp. If you do that-- I find it helpful to do a 'SELECT @d AS ColumnName'. (ColumnName being whatever you want to call that result column).
That way your result (if the value of @d was say...um.... 4) would be:

ColumnName
-----------
4

Hope that helps.

-katnthebag

Cogito cogito ergo cogito sum. - I think that I think, therefore I think that I am.
Go to Top of Page
   

- Advertisement -