how to create a JOB THET dependant ON NUMBER OF DATE

  • HOW TO CREATE A JOB THET RUN

    thet dependant in numbers of day

    ------------------------

    like this

    if the date of the insert in the table is old THEN 14 DAY

    THEN RUN THE JOB

    ---------------------------

    THNKS

    ILAN

  • ILAN,

    There are a number of ways to do what I think you are trying to do. If you want a job to run if a date on any row in a table is older than 14 days you will either need to have a job scheduled to run daily that checks for dates that have passed the expiration or you can create an INSERT/UPDATE trigger on the table that has the date and then use sp_add_job (and it's other variations) to create a job scheduled to run on the date+14 days.

    All of the above assumes that you are planning to use DTS. The daily job is probably better since it would be fairly complicated to go the other way. To use the trigger method you would probably want to check to make sure that you are not duplicating a scheduled run and a few other details. It really depends on your requirements.

    For information on checking to see if the date is 14 days old check out the BOL for DATEADD and DATEDIFF. There are other ways to handle it but I think these are what you are looking for.

    Jim

  • do you have a good example for run this job

    thnks

    ilan

  • can you try something like that:

    Create another job (will run every day) and put the following:

    if the date of the insert in the table is old THEN 14 DAY

    BEGIN

    msdb..sp_start_job 'Your JOB'

    END

    Go

Viewing 4 posts - 1 through 3 (of 3 total)

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