Job Scheduling

  • Hi everyone,

    how do i schedule a job to run for the previous day?

    i have SQL extracting daily statistics and every morning at 9am i need to run a job to extract the previous day's results

  • yisaaacs (1/21/2009)


    Hi everyone,

    how do i schedule a job to run for the previous day?

    i have SQL extracting daily statistics and every morning at 9am i need to run a job to extract the previous day's results

    Can you elaborate on what are jobsteps that run as a part of this job?

    Do you extract results from prodution tables or you mean to take out sql server performance statistics?



    Pradeep Singh

  • My query extracts the daily sales figures from production for the previous day and every morning at 9am a report is sent to management detailing everything that has happened the day before. I create a html email and send it off to required parties.

  • yisaaacs (1/21/2009)


    My query extracts the daily sales figures from production for the previous day and every morning at 9am a report is sent to management detailing everything that has happened the day before. I create a html email and send it off to required parties.

    Check for the queries (or SPs) that is being fired as a part of the job. It should have a WHERE clause which limits the rows for the previous day.

    may be something like where convert(varchar,SalesDate,112)=convert(varchar,getdate()-1,112)

    replace it with the exact date OR write getdate()-2



    Pradeep Singh

  • I would recommend using something like

    DATEADD(dd, DATEDIFF(dd,0,CURRENT_TIMESTAMP), -1)

    instead of the varchar cast. This will perform much faster... search here for "Date Only" and you should find plenty of posts as to why.

  • I’m making some assumptions about your request, hope this helps.

    Seems like you are manually running some queries each day, probably copying and pasting the results from Management Studio into something else, then formatting it to send out a report.

    If that is the case you could take your queries and create stored procedures that insert the data into “working” tables. You can create a job that calls each stored procedure then schedule that job to run each morning.

    Each stored proc will truncate its working table and reload it with the previous day's data, then you can copy and format it to create your email.

    If my guess was way off post back and add some detail about your requirements.

  • all is good. added a condition in the where clause.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply