Use output parameter in a store proc

I have two store procs : proc 1 and proc 2.

inside proc 1 i call proc 2. proc 2 has an output parameter  @var1. after running proc 2 i return back to proc 1. when i come back to proc 1 i want to use the output parameter from proc 2. can i do that. please give me an example.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

give this a go:

create proc proc2
@var1 int output
set @var1 = 5

create proc proc1
declare @outputval int
exec proc2 @var1 = @outputval output

select @outputval
pratikshahseAuthor Commented:
this does not work.
it keeps on saying

Procedure or function 'proc2' expects parameter '@var1', which was not supplied.
post your code...
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

pratikshahseAuthor Commented:
proc 1

CREATE PROCEDURE [dbo].[save_basedata_program]
      @BaseDataProgramID int Output,      
    @Description varchar(50),
      @ConsequenceGroupID      int,      
      @AttributeID int,
       @BasedataProgramTypeID int,
    @EnginePackageID int,
    @EffectiveDate    DateTime,
    @ExpirationDate DateTime,
      @DeActivateDate DateTime,
      @ClauseGroupXML xml



      @ErrNo                int,
      @ErrMsg               varchar(255),
      @iRowCount            int,
      @ClauseGroupID            int,
      @outputval int

set @ClauseGroupID = 0
Begin Tran
if (@DeActivateDate IS NULL OR @DeActivateDate =  '1/1/1900 12:00:00 AM')

-- Call Save Clause Group
select @ClauseGroupXML
select @ClauseGroupID
exec save_engine_clause_group ClauseGroupXML,@ClauseGroupID = @outputval output
select @ClauseGroupID

proc 2

ALTER PROCEDURE [dbo].[save_engine_clause_group]

    @ClauseGroup  xml,      
    @EngineClauseGroupID int output




sql code

RETURN @EngineClauseGroupID
      RAISERROR @ErrNo @ErrMsg
      RETURN -1
Your procedure save_engine_clause_group has two params, but you're only passing in the first one.  You'll need to pass in an XML param and then the 2nd param followed by the OUTPUT statement

pratikshahseAuthor Commented:
so if i do something like this
exec save_engine_clause_group ClauseGroupXML,@ClauseGroupID, @var = @outputval output

it says too many arguments

try this instead:

exec save_engine_clause_group
@ClauseGroup  = @ClauseGroupID,      
@EngineClauseGroupID = @outputval output

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Virtual Server

From novice to tech pro — start learning today.