Question : Calling a stored procedure from a stored procedure

How would i call a stored procedure from another stored procedure?

For example the first stored procedure as a input parameter of say:

@compID int

and a query that has:

select SaleID, OtherFieldsETc WHERE companyid = @companyID

Now, i want to pass SalesID AND @companyID to a third procedure and have the result be one of the fields returned in the first stored procedure.



Answer : Calling a stored procedure from a stored procedure

you should check if you can change the procedure you want to call into a (scalar) function, then you can include it in the query
1:
2:
3:
4:
select t.SaleID, t.OtherFields 
, dbo.YourFunction(t.SaleID, @companyID) x
FROM yourtable t
WHERE t.companyid = @companyID
Random Solutions  
 
programming4us programming4us