Question : What would you expect these SQL UPDATE statements to do?

update BILLTOS
set BILLTOS.Email = PATIENTS.Email
from PATIENTS, BILLTOS
where PATIENTS.BillToID = BILLTOS.BillToID
and PATIENTS.Relationship = '1'
and PATIENTS.Email like '%@%'
and not(BILLTOS.Email like '%@%');
update PATIENTS
set PATIENTS.Email = BILLTOS.Email
from PATIENTS, BILLTOS
where PATIENTS.BillToID = BILLTOS.BillToID
and PATIENTS.Relationship = '1'
and BILLTOS.Email like '%@%'
and not(PATIENTS.Email like '%@%')



The PATIENTS.Relationship column is set to '1' when the Patient is the BillTo party, only one patient can have this setting with any given BillToID.

Just trying to get verification of what this does before I run it on a live Database of several thousand records.  

Answer : What would you expect these SQL UPDATE statements to do?

1. Update billto email with patient email for all records in billto where
billto ids matching between patient and billto and patient relationship is '1' and patients email id contains @ and billto email does not contain @

2. Exactly same as  above for updating patients table

i.e. at the end of execution,. you would not have any records which have email id containing @ only in one table but are present in both the table (though the email ids could be different if both had @ already)
Random Solutions  
 
programming4us programming4us