Saturday, February 25, 2012

Call a stored procedure from another stored procedure

How do I call a stored procedure from a stored procedure, returning a value?
With Getvalue being the name of the stored procedure,
I've tried:
Set @.value = (getvalue(p1, p2))
Set @.value = exec getvalue(p1, p2)
and various other syntax all keep getting "getvalue is not a function"
Thanks for your help."et" <eagletender2001@.yahoo.com> wrote in message
news:uf8qGGnpFHA.1444@.tk2msftngp13.phx.gbl...
> How do I call a stored procedure from a stored procedure, returning a
> value?
> With Getvalue being the name of the stored procedure,
> I've tried:
> Set @.value = (getvalue(p1, p2))
> Set @.value = exec getvalue(p1, p2)
> and various other syntax all keep getting "getvalue is not a function"
> Thanks for your help.
>
>
it's
Declare @.p1 Int
Declare @.p2 Int
Declare @.Value Int
exec @.value = getvalue @.p1, @.p2
Don't forget to correct the datatypes, but you should know that already.
Regards
Colin Dawson
www.cjdawson.com|||The problem is that you cannot make us your own syntax :)
declare @.p1 type,
@.p2 type,
@.value type
set @.p1 = 'value'
set @.p2 = 'value'
EXEC @.value = dbo.getvalue @.parmname1 = @.p1, @.parmname2 = @.p2
or
EXEC @.value = dbo.getvalue @.p1, @.p2
It is best to name the parameters to protect against change, but either way
works just fine.
--
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"et" <eagletender2001@.yahoo.com> wrote in message
news:uf8qGGnpFHA.1444@.tk2msftngp13.phx.gbl...
> How do I call a stored procedure from a stored procedure, returning a
> value?
> With Getvalue being the name of the stored procedure,
> I've tried:
> Set @.value = (getvalue(p1, p2))
> Set @.value = exec getvalue(p1, p2)
> and various other syntax all keep getting "getvalue is not a function"
> Thanks for your help.
>
>|||You can only return an INT from a stored procedure:
DECLARE @.RC INT
EXEC @.RC = getvalue @.p1, @.p2
You can use an output parameter, however:
DECLARE @.out1 type
EXEC getvalue @.p1, @.p2, @.out1 OUTPUT
"et" <eagletender2001@.yahoo.com> wrote in message
news:uf8qGGnpFHA.1444@.tk2msftngp13.phx.gbl...
> How do I call a stored procedure from a stored procedure, returning a
value?
> With Getvalue being the name of the stored procedure,
> I've tried:
> Set @.value = (getvalue(p1, p2))
> Set @.value = exec getvalue(p1, p2)
> and various other syntax all keep getting "getvalue is not a function"
> Thanks for your help.
>
>|||Perfect! Thanks so much.
"Brian Selzer" <brian@.selzer-software.com> wrote in message
news:%23xoUFktpFHA.3244@.TK2MSFTNGP09.phx.gbl...
> You can only return an INT from a stored procedure:
> DECLARE @.RC INT
> EXEC @.RC = getvalue @.p1, @.p2
> You can use an output parameter, however:
> DECLARE @.out1 type
> EXEC getvalue @.p1, @.p2, @.out1 OUTPUT
>
> "et" <eagletender2001@.yahoo.com> wrote in message
> news:uf8qGGnpFHA.1444@.tk2msftngp13.phx.gbl...
> value?
>|||Good guess :) I didn't even think about the int thing
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Brian Selzer" <brian@.selzer-software.com> wrote in message
news:%23xoUFktpFHA.3244@.TK2MSFTNGP09.phx.gbl...
> You can only return an INT from a stored procedure:
> DECLARE @.RC INT
> EXEC @.RC = getvalue @.p1, @.p2
> You can use an output parameter, however:
> DECLARE @.out1 type
> EXEC getvalue @.p1, @.p2, @.out1 OUTPUT
>
> "et" <eagletender2001@.yahoo.com> wrote in message
> news:uf8qGGnpFHA.1444@.tk2msftngp13.phx.gbl...
> value?
>

No comments:

Post a Comment