Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:35:27+00:00 2026-06-12T19:35:27+00:00

After originally composing several reports by hand as part of an MVC 3 (EF4)

  • 0

After originally composing several reports by hand as part of an MVC 3 (EF4) project for a customer, I have decided it is far easier to compose reports in Microsoft reporting services (SSRS 2008 on SQL server 2008). For most of my reports this has proven to be a breeze, not even having to write SQL procs for most of my reports (semantic query in BIDS based on model).

However one report remains daunting due to the nature of its input parameters and originally being computed in a function returning a list, not a LINQ query. The goal is to return all people in the people table who are less than x percent busy on any day in the range between date a and date b (variables input by report requester). This busy level information only exists in the Job table which has information on which person it is assigned to, the start and end dates of the job, and its task level. As a result, my original C# function does pretty much the following (psuedo-code):

given startDateRange a, stopDateRange b, busyLevel x
{
for each person in people:
   List returnPeople = new List()
   create array consisting of days from a to b
   for each job in jobs:
      for each intersecting date of DateRange and job dateRange:
         add task level of job to array
   for each day in array:
      if array[day] < x
         returnPeople.Add(person)
         break;
return returnPeople
}

Table structure for relevant pieces:

People Table:
-PersonID (PK)
-other stuff...

Jobs Table:
-JobID (PK)
-StartDate
-StopDate
-Allocation
-AssignedPersonID (FK to People Table)

As you can see, a job is on someones schedule if that job’s AssignedPersonID is = that someone

So… since I’m now working in SSRS 2008, I am looking for guidance on how to get these same results in SSRS from the same input parameters. Some trick to semantic queries that I am currently unaware of? SQL stored proc with temp table or table variable? Some sort of data processing extension? Any information on what the best approach to this type of problem is would be much appreciated.

Let me know if additional information/code is required.

EDIT: Currently working on a solution using cursors and temp tables that pretty much copies the structure of my original function. This is DEFINITELY not ideal however due to the complexity and inefficient nature of cursors, so advice/alternatives would be helpful.

EDIT: Found a solution, definitely not the most efficient. Will change accepted answer if someone has a significantly faster method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:35:28+00:00Added an answer on June 12, 2026 at 7:35 pm

    Sorry that it took a while to get back to you. I don’t think there’s a way to get around having to loop through the days with a WHILE loop, since that gives you individual days needed to compare to your users’ input range. I think this query should help somewhat for speed though, since it doesn’t use any cursors. I added the logic within the WHILE loop, so you only loop one time through, and you have your temp table as a result. The variable names might be a little different, and you might switch a <= to < or something, but the main logic is there.

    The query includes the start date and end date, and is set to include anyone with an allocation less than or equal to the users’ input. I hope it helps you:

    DECLARE @startDate datetime, @endDate datetime, @maxAllocation float, @dayCounter datetime
    
    DECLARE @PeopleList TABLE (PersonId int, PersonName varchar(50))
    
    SET @dayCounter = @startDate
    WHILE @dayCounter <= @endDate
    BEGIN
        INSERT INTO @PeopleList SELECT P.PersonId, P.PersonName FROM People P INNER JOIN Jobs J ON P.PersonId = J.AssignedPersonId
           WHERE J.StartDate <= @dayCounter AND J.StopDate >= @dayCounter
           GROUP BY P.PersonId, P.PersonName
           HAVING SUM(J.Allocation) <= @maxAllocation
        SET @dayCounter = DATEADD(DAY, 1, @dayCounter)
    END
    
    SELECT DISTINCT PersonId, PersonName FROM @PeopleList
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After it turned out that what I originally wanted is probably not possible w/o
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
After deploying WCF server (svc) on my Server, I have got this message when
After modifying my C code, (written originally for Windows and compiled under VS 2008),
I have an old project from the 1990's I desperately need to compile. The
I look after builds of our products and have been asked to come up
I'm trying to use DDD in my current project (c#, mvc, nhibernate, castle) and
After compiling a simple C++ project using Visual Studio 2008 on vista, everything runs
I made the mistake of modifying my original source after importing it into subversion.
Possible Duplicate: Determine original name of variable after its passed to a function. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.