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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedures - Returning String Values

Status
Not open for further replies.

Azathoth

Technical User
Jul 14, 2003
61
US
I have a stored procedure (SP1) that calls another stored procedure (SP2). In SP2, a variable (@test_codes) is declared and assigned a comma-delimited list of values. SP1 wants to get this string from SP2 and store it in a variable, but I'm not sure how to make that work.

Is there some way to return or select @test_codes from SP2 such that SP1 can grab it?
 
You will need to code SP2 to include an OUTPUT parameter and code SP1 to capture the OUTPUT from SP2.

Search for output parameters in BOL, then choose Returning Data Using OUTPUT Parameters from the titles available.

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Ok, try this out. In sp2's parameter declartions type this;


create procedure sp2
@RETURN_VALUE varchar(50) output
as
/rest of procs code
set @RETURN_VALUE = @test_codes


Declare a variable in sp1 to hold the text and use the following line when calling sp2 to bring back the string


declare @test_codes
exec sp2 @test_codes output

That should get you started
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top