Hello,
I am trying to create a Stored procedure in the following way:
CREATE PROC RetroReport
@RetroCreated int output,
@RetroShipped int output,
@RetroCancelled int output,
@Retro2DayGap int output
AS
SELECT @RetroCreated =(Select count(*) FROM Retrofit_Orders where date_created >= DATEADD(day, -7,getdate()))
SELECT @RetroShipped =(SELECT count(*) FROM Retrofit_Orders where deliverynote_printed >= DATEADD(day, -7,getdate()))
SELECT @RetroCancelled = (SELECT count(*) FROM Retrofit_Orders where date_voided >= DATEADD(day, -7,getdate()))
SELECT @Retro2DayGap = (SELECT count(*) FROM Retrofit_orders where Datediff(day,date_created,deliverynote_printed) > 2 or Datediff(day,date_created,date_voided) > 2)
GO
I was hoping that it would return 4 values (1 for each query). However, when i try to run it I get an error saying
Procedure 'RetroReport' expects parameter '@RetroCreated', which was not supplied.
This doesn't make sense as I have specified that all the parameters as output values.
What am i doing wrong?
Neil
I am trying to create a Stored procedure in the following way:
CREATE PROC RetroReport
@RetroCreated int output,
@RetroShipped int output,
@RetroCancelled int output,
@Retro2DayGap int output
AS
SELECT @RetroCreated =(Select count(*) FROM Retrofit_Orders where date_created >= DATEADD(day, -7,getdate()))
SELECT @RetroShipped =(SELECT count(*) FROM Retrofit_Orders where deliverynote_printed >= DATEADD(day, -7,getdate()))
SELECT @RetroCancelled = (SELECT count(*) FROM Retrofit_Orders where date_voided >= DATEADD(day, -7,getdate()))
SELECT @Retro2DayGap = (SELECT count(*) FROM Retrofit_orders where Datediff(day,date_created,deliverynote_printed) > 2 or Datediff(day,date_created,date_voided) > 2)
GO
I was hoping that it would return 4 values (1 for each query). However, when i try to run it I get an error saying
Procedure 'RetroReport' expects parameter '@RetroCreated', which was not supplied.
This doesn't make sense as I have specified that all the parameters as output values.
What am i doing wrong?
Neil