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

calling a stored procedure

Status
Not open for further replies.

nnmmss

Programmer
Sep 7, 2004
123
0
0
IR
can i call a stored procedure inside another stored procedure?

tahnks
 
can you give a sample?
is this ok?
CREATE PROCEDURE CheckPRF @projId int,@TodayDate varchar(20) AS
call SecStored (@projId,@TodayDate)
Go

CREATE PROCEDURE SecStored @projId2 int,@TodayDate2 varchar(20) AS
print projId2
print TodayDate2
go
 
>> call SecStored (@projId,@TodayDate)


EXEC SecStored @projId, @TodayDate


Hope this helps.

[vampire][bat]
 
Needs cleaned up a little but works:

CREATE PROCEDURE CheckPRF (@projId int,@TodayDate varchar(20)) AS
exec SecStored @projId,@TodayDate
GO

CREATE PROCEDURE SecStored @projId2 int,@TodayDate2 varchar(20) AS
print @projId2
print @TodayDate2
GO


From Query Analyzer:

CheckPRF 2222,'01/01/2006'

 
and what if i want to have an output back from the SecStored to the CheckPRF ?
 
Using the above example:

Code:
ALTER PROCEDURE CheckPRF @projId int,@TodayDate varchar(20) AS
declare @Result varchar(100)
exec SecStored @projId,@TodayDate, @Result output
print @Result
GO

ALTER PROCEDURE SecStored @projId2 int, @TodayDate2 varchar(20), @RetVal varchar(100) output AS
print @projId2 
print @TodayDate2 
set @RetVal = 'Fred'
GO


CheckPRF 2222,'01/01/2006'

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top