I have stored procedure A and want to call store procedure B from A by passing a @mydate
parameter. Stored procedure B will return a rowset which I can further use in procedure A.
I researched this on Google but did not find anything without using a temporary table. Is there an easy way to get this without a temp table.
P.S.: I tried to get this done using stored procedure as A and a function as B easily. But want to know if I can get it done only by using stored procedures.
In releases earlier than SQL Server 2000, you can call one stored procedure from another and return a set of records by creating a temporary table into which the called stored procedure (B) can insert its results or by exploring the use of CURSOR variables.
Create PROCEDURE Stored_Procedure_Name_2 ( @param1 int = 5 , @param2 varchar(max), @param3 varchar(max) ) AS DECLARE @Table TABLE ( /*TABLE DEFINITION*/ id int, name varchar(max), address varchar(max) ) INSERT INTO @Table EXEC Stored_Procedure_Name_1 @param1 , @param2 = 'Raju' ,@param3 =@param3 SELECT id ,name ,address FROM @Table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With