Create Proc EarlyArrivalAM
as
create table #TempTbl1 (
Date smalldatetime,
ArrivalAM smalldatetime,
DepartureAm smalldatetime,
ArrivalPm smalldatetime,
DeparturePm smalldatetime
)
create table #TempTbl2 (
Date smalldatetime,
ArrivalAM smalldatetime,
DepartureAm smalldatetime,
ArrivalPm smalldatetime,
DeparturePm smalldatetime
)
insert into #tempTbl1 (Date) select distinct Date from FlightPlan
insert into #tempTbl2 select * from FlightPlan order by ArrivalAm
update t1 set t1.ArrivalAM = t2.ArrivalAm,
t1.DepartureAm = t2.DepartureAM,
t1.ArrivalPm = t2.ArrivalPM,
t1.DeparturePM = t2.DeparturePm
from #TempTbl1 t1, #TempTbl2 t2
where t1.Date = t2.Date
select * from #TempTbl1