update cn
set ReadyToBeSent = 1
from AKUZ.T_CARD_NOTE cn where 
ReadyToBeSent = 0
and not exists (select * from AKUZ.T_CARD_NOTE_SIGNATURE cns where cns.CardNote = cn.MedicalRecordID)
and exists (select * from AKUZ.T_CARD_NOTE_FILE cnf where cnf.CardNote = cn.MedicalRecordID)
GO