T-SQL script - logic issues with timeline
Two temp tables are created and then loaded...Here's the schema. Create table #SH ([date] datetime, sched_id int, agent_id int) Create table #SD (sched_id int, start_minute int, length int, exception_code int) (Schema and design is something I can't change unfortunately, both temp tables are loaded from flat files. I can introduce and load new temp tables if needed). A little background - The #SH header table holds a persons schedule as 'Start_minute' and goes for 'schedule_length' in minutes. For example, if start minute and schedule length were both 480, that would read as 8am (8am = 480th