February 2, 2005 at 9:01 am
Hi
all
how can pass one sp(stored procedure) output values to other sp input values
February 2, 2005 at 9:26 am
Declare @MyParam as int
set @MyParam = 6
EXEC dbo.MySP1 @MyParam output
--let's say that MySP1 set the param to 8
EXEC dbo.MySP2 @MyParam
February 3, 2005 at 1:54 am
If it would make sense in your context, you could call one stored procedure from another.
Thus Procedure A calls Procedure B and then uses the output from Procedure B to do its work.
Within procedureA
Decalare @param as [datatype]
exec dbo.ProcedureB @param output
[do the work of ProcedureA using the value of @param]
February 3, 2005 at 11:56 am
Create Procedure TestB (@Parameter1 Varchar(10),@Parameter2 Varchar(10) Output) as
Select 'Inside TestB @Parameter1 : ',@Parameter1,'@Parameter2 : ',@Parameter2
Select @Parameter2='1'
Return
go
Create Procedure TestA (@Parameter1 Varchar(10)) as
Declare @Parameter2 Varchar(10)
Select @Parameter2='1',@Parameter1='0'
Select 'TestA Before @Parameter2 : ',@Parameter2
Exec TestB @Parameter1,@Parameter2 Output
Select 'TestA After @Parameter2 : ',@Parameter2
Return
go
Exec TestA 'A'
Go
Drop procedure TestA
Drop Procedure TestB
Go
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply