• My first suggestion to you would be to remove the tbl_ from your table names as I find that convention totally annoying. You're not programming C or C# here, so there is no need to prefix the object type on the name. SSMS does a pretty good job of segregating objects and doesn't get confused on that point.

    Perhaps this query will get you started:

    ;WITH GroupsOfWeeks AS (

    SELECT *

    ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5)

    FROM [dbo].[tbl_dates]

    )

    SELECT Dates, Holidays, DayDates, DayHolidays, names

    FROM GroupsOfWeeks

    INNER JOIN [dbo].[tbl_names] ON n = id

    ORDER BY Dates

    It distributes the names across alternating weeks, with each person assigned to 5 consecutive days in your dates table. Since there are 251 rows in this table, George gets to work an extra day.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St