update AKUZ.T_MEDICAL_RECORD mr
set  RecordDate = COALESCE(mr.RecordDate, mr.RecordTime, acr.PostingDate, '20240101'), RecordTime = COALESCE(mrr.RecordDate, mrr.RecordTime, acr.PostingDate, '20240101')
from AKUZ.T_MEDICAL_RECORD mrr
left join AKUZ.T_AMBULANCE_CARD_RECORD acr on acr.MedicalRecordID = mrr.MedicalRecordID
where mrr.MedicalRecordID = mr.MedicalRecordID and (mr.RecordDate is null or mr.RecordTime is null );

ALTER TABLE AKUZ.T_MEDICAL_RECORD ALTER COLUMN "recordtime" SET NOT NULL;
ALTER TABLE AKUZ.T_MEDICAL_RECORD ALTER COLUMN "recorddate" SET NOT NULL;