To get result from another stored procedure

In SQL , to execute a SP from another sp and get the resultset as table format use the following code

Stored Procedure 1

Create PROCEDURE  [Sp_Report1]
  @cid bigint=0 

select Description,CurrentValue from table1




Stored Procedure 2

Create PROCEDURE  [Sp_Report2]
  @cid bigint=0 

declare @tableInvestment table (Description nvarchar(50), CurrentValue decimal(18,5) ) 
insert into @tableInvestment 

exec Sp_Report1 2                  — 2 is the parameter value for @CID

select * from  @tableInvestment 





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s