
update reservationroomline
set statusrl = r.status
from reservations r (nolock)
inner join reservationroomlinextab rlx (nolock) on r.referencenumber = rlx.referencenumber and r.guestnumber = rlx.guestnumber
inner join reservationroomline rl (nolock) on rl.linenumber = rlx.linenumber
where r.status > 4 and r.status <> rl.statusrl