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 
  AS
BEGIN

select Description,CurrentValue from table1

end 

—————————————–

 

Stored Procedure 2

Create PROCEDURE  [Sp_Report2]
  @cid bigint=0 
  AS
BEGIN

 
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 

end 

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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