Recurrsion in T-SQL

  • Question: How can I make a recursive algorithm in TSQL without using a large amount of resources?

    Situation: New hires are put on a 6 month probation period, Their probation ends at the 6 month mark + sick time isnull(floor(sick_hours/8),0) they accrued during that 6 months. Their accrued sick days are added to the 6 month probation period to establish a new probation end date.

    I then have to do the following loop:

    1)Determine if any of the days between the original probation end date and the new probation end date have any weekend days or holidays for a particular employee.

    2)If it does, I add those days to the new probation end date to create a newer probation end date.

    a.I then go back up to step 1).

    3)If it does not, I jump out of loop and look at the next employee on probation.

    Note: I already have coding for determining number of sick days accumulated during an employee’s probation period. Recursive CTE? Recursive function? Other? Do you have any examples I can check out? I am semi-new to SQL.

    Steve Grusis
    Progrmamer/Analyst
    State Center Community College District
    Fresno CA
    (559) 244-5958

Viewing 0 posts

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