How to execute such procedure?

Hi all!

I have a procedure (prepared not by me). It is creating some data and making some calculations, that is not important here. The main case is that this procedure is execute for one week. There is @week parameter and all calculations are based on this week.

It is sth like this

CREATE procedure [dbo].[raport]
@week varchar(8)='20140203', @ps varchar(2)='ps' 
as

And the problem is that this procedure needs to be executed once for few weeks, I mean someone need data for 20150101 & 20150102 & 20150103 & 20150104

Is it possible to execute it 4 times to get 4 sets of data at one time but by executing it ONCE not 4 times separately?

August 27th, 2015 2:50am

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5735e283-3268-4a79-a1c3-2a81b6982a08/how-to-run-a-sql-server-agent-job-step-on-certain-daysfrequency?forum=sqldatabaseengine

Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 2:55am

Unfortunately i cant use any tools like this, I can use only sql code
August 27th, 2015 2:58am

But thinking about jobs... maybe it would work. The only thing my system knows is to execute something, always we execute pure procedures, nothing more. But maybe it is worth trying to execute a job. But tell me please, if i would prepare a job for executing my procedure, how to execute it with one command for N weeks? 

For example i will have a job 'Calculate data' with executes my procedure [dbo].[report], it has parameter @week

How to execute this job for N weeks? How to send these weeks there? 



  • Edited by axn22 14 minutes ago
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 3:09am

Hi

Actually this thread explain how to do that, you need to create a job and simple schedule it for every day let's say,

This job will have two steps, in the first step you will have to check if today is a correct day to run the job, then steps returns 1 and move to the next step (stored procedure's execution) if it does not , it just throws an error and exit (without going to the next step)

August 27th, 2015 3:18am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics