Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An SP calling another

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can an SP “call” another SP ?
If so, how can it’s result be retrieved ?

eg
create procedure getvar
as
declare @var1 numeric
select @var1 = (convert(numeric(16), select etc etc)


create procedure get-getvar
as
declare @var2 numeric
exec getvar <- This will display @var1, but
How do I get @var1 from getvar into @var2 ?
select @var2

Thanks
 
If I've understood your question, then you could try this:

create procedure getvar
@var1 numeric OUTPUT
as
select @var1 = (convert(numeric(16), select etc etc)

create procedure get-getvar
as
declare @var2 numeric
exec getvar @var2 OUTPUT
select @var2


... note the use of the OUTPUT declarative and that it needs to be used both in the called procedure and the calling one.

HTH,

Mike
 
You use 'output' parameters :-

create procedure getvar @var1 numeric
as
select @var1 = (convert(numeric(16), select etc etc)


create procedure get-getvar as
declare @var1 numeric
exec getvar @var1 output
select @var1 etc etc

HTH ;-)

Dickie Bird
db@dickiebird.freeserve.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top