October 14, 2005 at 12:53 pm
I have 2 SP's,the result of the 1st SP shud be passed as parameter to the second SP,can any help me how to do this.
October 14, 2005 at 1:00 pm
if the "result" of sp1 is a variable then just use the output keyword
create proc sp1 @data_in int, @data_out int output
as
set @data_out = @data_in -1
create proc sp2 as
begin
declare @i int, @o int
set @i = 3
exec sp1 @i, @o output
select @o
end
Cheers!
* Noel
October 14, 2005 at 1:03 pm
create procedure sp1 @parm1 Int, @parm2 VarChar(25), .... as select @parm1 = col1, @parm2 = col2 from myTable where.... if @@rowcount > 0 begin exec sp2 @parm1, @parm2... end
**ASCII stupid question, get a stupid ANSI !!!**
October 14, 2005 at 1:04 pm
3 minutes late....and another perspective ???
**ASCII stupid question, get a stupid ANSI !!!**
October 14, 2005 at 1:07 pm
CREATE PROCEDURE dbo.A
(
@PersonnelNumber As Integer
 
as
SELECT e.DisciplineID
FROM Employees e
WHERE
e.PersonnelNumber = @PersonnelNumber
GO
CREATE PROCEDURE dbo.B
(
@DisciplineID As Integer
 
as
SELECT s.SkillName,
s.SkillID
FROM Skills s
WHERE Inactive = 0
AND
(s.DisciplineID = @DisciplineID OR s.DisciplineID=5)
GO
Ok here the result SP A shud be the parameter for SP B
October 14, 2005 at 1:28 pm
Jp, Hopefully you understand this:
CREATE PROCEDURE dbo.A
(
@PersonnelNumber As Integer,
@dis_id int output
)
as
SELECT e.DisciplineID
FROM Employees e
WHERE
e.PersonnelNumber = @PersonnelNumber
GO
--------------------------------------------------------------------------------
CREATE PROCEDURE dbo.B
(
@PersonnelNumber As Integer
)
as
Declare @DisciplineID int
exec dbo.A @PersonnelNumber, @DisciplineID output
SELECT s.SkillName,
s.SkillID
FROM Skills s
WHERE Inactive = 0
AND
(s.DisciplineID = @DisciplineID OR s.DisciplineID=5)
GO
* Noel
October 14, 2005 at 1:28 pm
CREATE PROCEDURE dbo.A ( @PersonnelNumber As Integer as Declare @DisciplineID Int SELECT @DisciplineID = e.DisciplineID FROM Employees e WHERE e.PersonnelNumber = @PersonnelNumber if @@rowcount > 0 begin exec dbo.B @DisciplineID end GO CREATE PROCEDURE dbo.B ( @DisciplineID As Integer [Wink] as SELECT s.SkillName, s.SkillID FROM Skills s WHERE Inactive = 0 AND (s.DisciplineID = @DisciplineID OR s.DisciplineID=5) GO
**ASCII stupid question, get a stupid ANSI !!!**
October 14, 2005 at 1:30 pm
TGIF - have a great weekend everyone!
**ASCII stupid question, get a stupid ANSI !!!**
October 14, 2005 at 1:33 pm
You too!!!!
* Noel
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply