• I realize you don't want to redesign your system, but this is code-parsing at best, painful at worst.

    There are a few components you need here, particularly if you want to keep user-friendly terms for your users instead of having them setup things with significant complexity.

    First, you need to get these standardized. You want to make sure all options are in a table of their own that you can add attributes to for future calculation inclusions.

    Next, you will want a calendar table that has attributes associated with the different days. These are flags that will correspond to your standardized choices table.

    For example, in your calendar table, you'd have a date, then some extra flags, such as "First Monday" 0/1, "Second to last Monday" 0/1... etc.

    Then, when you're deciding which reports will run on what day, you'd go to the calendar table, find the active flags, go to the standardized list table, find out who's active for those flags, then finally take those values backwards into your report list to determine what to run.

    This isn't a quick query to help you with, particularly not urgently, it's a design overhaul.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA