• Luis,

    Here is the new set of data just on one location & sheet with expected results, if that helps.

    Insert into [W_O_Schedule] Values

    --Nothing from here since No Location Schedule

    --SO Nothing

    (1,1,'Available','Weekly','2013-06-03 00:00:00','2013-06-03 20:00:00',1),

    (1,1,'Available','OneTime','2013-06-03 00:00:00','2013-06-03 20:00:00',1),

    --Nothing from here since IsResSchedule = 0 for both rows --No ResourceSchedule

    --SO Nothing

    (1,2,'Available','Weekly','2013-06-03 00:00:00','2013-06-03 20:00:00',0),

    (1,2,'Available','OneTime','2013-06-03 00:00:00','2013-06-03 20:00:00',0),

    --From the below 2 I wasnt only row with 'Unavailable'

    (1,3,'Available','Weekly','2000-01-03 09:00:00','2000-01-03 17:00:00',1),

    (1,3,'Unavailable','OneTime','2013-06-03 00:00:00','2013-06-04 00:00:00',0),

    --Only row 1 and 2 from here Resource wide open but Location is restricted

    (1, 4,'Available','Weekly','2000-01-03 09:00:00','2000-01-03 12:00:00',0),

    (1, 4,'Available','Weekly','2000-01-03 13:00:00','2000-01-03 17:00:00',0),

    (1, 4,'Available','Weekly','2000-01-03 09:00:00','2000-01-03 17:00:00',1),

    -- Location wide open but Resource is restricted row 1 & 2 only

    (1, 5,'Available','Weekly','2000-01-03 09:00:00','2000-01-03 12:00:00',1),

    (1, 5,'Available','Weekly','2000-01-03 13:00:00','2000-01-03 17:00:00',1),

    (1, 5,'Available','Weekly','2000-01-03 09:00:00','2000-01-03 17:00:00',0),

    -- Only Unavailable row

    (1,6,'Available','Weekly','2000-01-04 09:00:00.000','2000-01-04 17:00:00.000',0),

    (1,6,'Available','Weekly','2000-01-04 09:00:00.000','2000-01-04 17:00:00.000',1),

    (1,6,'Unavailable','OneTime','2013-06-04 00:00:00.000','2013-06-05 00:00:00.000',0),

    (1, 6,'Unavailable','OneTime','2013-06-04 00:00:00.000','2013-06-05 00:00:00.000',1)