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

assign sp result to a variable

Status
Not open for further replies.

piti

Technical User
Apr 12, 2001
627
SK
hi
i have stored procedure without parameters and i need to assign the result of this procedure to a variable in a script/another sp
using
exec @var = sp_name
returns, as it should, the return code, and i just can't figure out a solution how to assign the sp result to the variable
i can't change the sp
1. to have an output var
2. to set the result as a return code
so if somebody knows how to do that please help
thanx
 
Here is an example with an output variable.
Code:
CREATE PROCEDURE usp_TARND_TURNAROUNDDATE @TADate VARCHAR(10) OUTPUT, @RecDate VARCHAR(10) = '12/22/2004',
       @TurnAroundDays INT = 2
--Created by XXXX on 2004-06-11 12:26:04.767
AS
DECLARE @TADays INT

SET @TADate = @RecDate
SET @TADays = @TurnAroundDays
WHILE @TADays > 0 BEGIN
    SET @TADate = CONVERT(VARCHAR(10), DATEADD(d, 1, CONVERT(DATETIME, @TADate)), 101)
    IF (SELECT COUNT(FDate) FROM T_TARND_DAYSOFYEAR WHERE FDate = @TADate AND FType <> 1) = 0
       SET @TADays = @TADays - 1   	
END

GO


DECLARE @D VARCHAR(10)
DECLARE @O VARCHAR(10)
SET @D = '09/05/2004'
EXEC usp_TARND_TURNAROUNDDATE @O OUTPUT, @D
PRINT @O

Let me know if you want an option 2 example.
 
as i said, the sp is without variables and i can't add a new output variable ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top