Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have two stored procedures that have the same input, the input contains (datefrom,dateto and accountId). The first stored procedure returns data according to date between from and to and the second stored procedure returns the data according to before the datefrom.
I want now to enter all these inputs and call the stored second stored in the first stored procedure. can any body help me in that. Please????
thanks alot
Posted
Updated 5-Apr-11 21:05pm
v2

 
Share this answer
 
Do you mean you want to pass several values to the second stored procedure. If that's the case, have a look at for example this article How to pass multiple records to a Stored Procedure[^].

In the article the calling end is a client but it could also be another stored procedure. The main point is to pass an unknown amount of values.
 
Share this answer
 
Do you want to merge the result of the two stored procedures into a single result? Then try this
SQL
-- create temporary table to store the result
IF OBJECT_ID('tempdb..#result')
   DROP TABLE #result
CREATE TABLE #result
   (
   datefrom  DATETIME NULL,
   dateto    DATETIME NULL,
   accountId INT      NULL
   )

-- insert from first proc
-- NOTE columns must in the same order as the proc result
INSERT INTO #result
   (
   datefrom,
   dateto,
   accountId
   )
EXEC firstProcedure @param1,@param2 -- replace with your procedure name and parameters

-- insert from second proc
-- NOTE columns must in the same order as the proc result
INSERT INTO #result
   (
   datefrom,
   dateto,
   accountId
   )
EXEC secondProcedure @param1,@param2 -- replace with your procedure name and parameters

-- final result
SELECT  *
FROM    #result
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900