Results 1 to 6 of 6

Thread: Need advice on a scheduling project with SQL backend

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question Need advice on a scheduling project with SQL backend

    I'm writing a project to schedule a task on certain days of the week at certain times. I have choices of 8:00 am, 8:15 am,.... 5:00 pm and choices for the seven week days.

    The problem with SQL is that the datetime field also needs a date, not just a time, but I don't want to have to restrict it to having a set date (unless I picked the minimum (Jan 1, 1753?) as the default date...

    One solution that I considered was to fill a table with all the future dates and times possibly available for scheduling like until Dec 31, 9999, but that would be a huge table. This would be easier for showing the next scheduled date/time the task should run but would be hard to set using certain times and days of the week as options.

    So my only solution was to have a table with an ID (int) and a varchar(8) to hold the time values and a table with an ID (int) and varchar(10) for days of the week.

    The problem comes when I want to show the scheduled date and time when the task is next scheduled to run. What's the simplest way to find this? And then do I store it or just calculate it for every task?

    I know this is long, but somebody surely has run into this before. Any suggestions will be appreciated.
    Last edited by wey97; Apr 11th, 2005 at 10:27 PM.

  2. #2
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463

    Re: Need advice on a scheduling project with SQL backend

    I don't quite understand....
    Here you are not concerned about saving the date:
    Quote Originally Posted by wey97
    The problem with SQL is that the datetime field also needs a date, not just a time, but I don't want to have to restrict it to having a set date (unless I picked the minimum (Jan 1, 1753?) as the default date...
    Here you want to have (all possible?) values until Dec 31,1999
    Quote Originally Posted by wey97
    One solution that I considered was to fill a table with all the future dates and times possibly available for scheduling like until Dec 31, 9999, but that would be a huge table. This would be easier for showing the next scheduled date/time the task should run but would be hard to set using certain times and days of the week as options.
    Is your goal having to run a task scheduled this Monday @8AM for next week on the same schedule?
    live, code and die...

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Need advice on a scheduling project with SQL backend

    You said SQL - so I'm assuming you mean MS SQL Server - right?

    Have you looked at the options available in ENTERPRISE MANAGER?

    Under DATA TRANSFORMATION SERVICES you create a LOCAL PACKAGE - when you have it all set, you SCHEDULE it.

    This schedule is extremely flexible and robust - all the features you want - times, days - everything.

    Once scheduled, the PACKAGE appears as a JOB under MANAGEMENT>SQL SERVER AGENT.

    The AGENT is responsible for running the JOB - and tracking job logs.

    Why are you looking to do this yourself when it's already available?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Need advice on a scheduling project with SQL backend

    Quote Originally Posted by dRAMmer
    I don't quite understand....
    Here you are not concerned about saving the date:
    Here you want to have (all possible?) values until Dec 31,1999

    Is your goal having to run a task scheduled this Monday @8AM for next week on the same schedule?
    Yes, that's the goal to run the task at 8AM, 9AM, 10AM.... whatever the user picks and on whatever days of the week they pick. With this I need to somehow calculate the next time the task will run. So I have three options: 1) Save all the times with some default date 1/1/1753 and ignore the date part 2) Save the times as a text field only 3) Save all possible date/time combinations for, say, the next couple hundred years (The more I think about it, this is a BAD idea)

    Quote Originally Posted by szlamany
    You said SQL - so I'm assuming you mean MS SQL Server - right?

    Have you looked at the options available in ENTERPRISE MANAGER?

    Under DATA TRANSFORMATION SERVICES you create a LOCAL PACKAGE - when you have it all set, you SCHEDULE it.

    This schedule is extremely flexible and robust - all the features you want - times, days - everything.

    Once scheduled, the PACKAGE appears as a JOB under MANAGEMENT>SQL SERVER AGENT.

    The AGENT is responsible for running the JOB - and tracking job logs.

    Why are you looking to do this yourself when it's already available?
    Yes, MS SQL Server, and the DTS in SQL won't be possible because I have many different clients who have to save options in this remote database and I have to write an application that will be running at all times on their machine to see if the task needs to be run.

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Need advice on a scheduling project with SQL backend

    I would save the times as a text field - you certainly aren't getting any gain treating them as a date.

    I guess you are planning to somehow save what "days of the week" the job should run also - right?

    I do believe you can get at DTS from VB - so maybe your "can't use DTS" and the regular scheduler AGENT issues can be overcome.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Need advice on a scheduling project with SQL backend

    Quote Originally Posted by wey97
    Yes, that's the goal to run the task at 8AM, 9AM, 10AM.... whatever the user picks and on whatever days of the week they pick. With this I need to somehow calculate the next time the task will run.
    Why not just store the date/time it should next run? (and probably another field to say the number of days to increment after it has run).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width