first of all you dont need the cursor hereSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO/****** Object: Stored Procedure dbo.carrierTest Script Date: 14/05/2008 16:35:40 ******/ALTER proc carrierauto --'2008','08','01','15'@pYear int, @pMonth int, @pDay1 int,@pDay2 int AsBeginSet nocount onDeclare @pOperator varchar (32)Delete from test_report select @pOperator = min(display name) from carrier test (no lock) While (@pOperator is not null)BeginInsert into test report exec carr_summary_Datewise @pYear, @pMonth,@pDay1,@pDay2,@pOperatorselect @pOperator = min(display name) from carrier test (no lock)where [display name] >@pOperator EndSet nocount offSelect * from test_report (nolock)endGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO
Now by running weekly do you mean passing a month value and running for all weeks of month? or do you want procedure to return you data of current week based on date in which it was run?