Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a stored procedure (with parameters) from another stored procedure without temp table

Tags:

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.

like image 764
SQLNewBee Avatar asked Dec 07 '11 20:12

SQLNewBee


People also ask

Can you call a stored procedure from another stored procedure?

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.


1 Answers

 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   
like image 172
Arun CM Avatar answered Sep 20 '22 14:09

Arun CM