Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calling a StoredProcedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-03-25 : 07:11:46
Patrick Florival writes "Sir:

I wish to call a StoredProcedure from another StoredProcedure, I am familiar with this (e.g. calling "Procedure_name" from "Procedure_Name2). However, how do I call the same StoredProcedure from another StoredProcedure it contains a parameter (see Example 2)?

CREATE PROCEDURE [PROCEDURE_NAME2]
AS

EXEC Procedure_Name


CREATE PROCEDURE [PROCEDURE_NAME]
AS
SELECT last_name, first_name
FROM Students

Example 1. No parameters.




CREATE PROCEDURE [PROCEDURE_NAME]
@lastname nvarchar (35)
AS
SELECT last_name, first_name
FROM Students
Where last_name = @last_name

Example 2. Parameters.

Thank you for your anticipated response."

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-25 : 08:35:55
--From within calling proc:
...
exec Procedure_Name @Last_name = 'Florival'

--OR

...
declare @Lastname varchar(30)
set @Lastname = 'Florival'
exec Procedure_Name @Last_name = @Lastname


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -