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
 Transact-SQL (2000)
 exec sp from another sp

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2004-12-22 : 03:11:57
Hi,

I have a sp that returns a list of customers whose status=5
such as
select customerid from customers where status=5

I want to run a second sp that will call the first sp but will return the cumstomerids that are bigger than 5 for example.

The result could return many rows.

Is there a way of doing it?

Thanks

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2004-12-22 : 03:28:21
Something like this??
This works on Northwind but returns 2 recordsets.
If you only want 1 rs then
WHERE status >= 5

CREATE PROC Sproc1 @EmpId int
AS
SELECT EmployeeId
FROM Employees
WHERE EmployeeId = @EmpId

EXEC Sproc2 @EmpId

--End of Sproc1

CREATE PROC Sproc2 @EmpId int
AS
SELECT EmployeeId
FROM Employees
WHERE EmployeeId > @EmpId

--End of Sproc2

EXEC Sproc1 5

Andy
Go to Top of Page
   

- Advertisement -