Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 inner procedure ouput problem

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2008-02-15 : 01:07:25

create procedure main
(
declare @posting_date varchar(20)='31 dec 2007'
declare @period varchar(50)=null
declare @month_wid int=0

exec avg_date_check @posting_date,@period,@month_wid
select @posting_date,@period,@month_wid
)

create procedure avg_date_check
(
@posting_date varchar(20),
@period varchar(50) output,
@month_wid int output
)
as
begin
--some logic
select @period='01 dec 2007 - 31 dec 2007',@monthwid=200712
return
end

when i execute the main sp the inner sp(avg_date_check) output is coming as null,can i any one correct my syntax

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-02-15 : 01:48:27
Hope this link helps you understand output parameters in SP.
http://www.sqlservercentral.com/articles/Stored+Procedures/outputparameters/1200/

You may need to register to view this article.
Go to Top of Page

Qualis
Posting Yak Master

145 Posts

Posted - 2008-02-15 : 12:53:34
Try:

Create Procedure Main
(
@posting_date varchar(20) = '31 dec 2007',
@period varchar(50) = null,
@month_wid int = 0
)
As Begin
Declare @Result Table (Period varchar(50), Month_Wid int)

Insert Into @Result
Exec Avg_Date_Check @posting_date, @period, @month_wid

Select @posting_date, Period, Month_Wid
From @Result
End
Go

Create Procedure Avg_Date_Check
(
@posting_date varchar(20),
@period varchar(50),
@month_wid int
)
As Begin
--some logic
Select '01 dec 2007 - 31 dec 2007', 200712
Return
End
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-16 : 01:42:41
Are you trying to retrieve values of parameters from second sp. then use OUPUT keyword with them. like:-
exec avg_date_check @posting_date,@period OUTPUT,@month_wid OUTPUT
Go to Top of Page
   

- Advertisement -