Add where
condition in sql to check is_updated
(0 or 1) and update_date
like:
UPDATE S
SET s.naics_cd = left(n.naic, 6),
s.naics_desc = substring(n.naic, 9, 255)
from mtb..staging_cust_acct s
right outer join mtb_aml..tb_party_kyc e
on e.customerinternalid = s.party_key
right outer join mtb_aml..tb_ref_naic n
on e.d_case_id = n.d_case_id
WHERE s.is_updated=0 --Added Condition
AND s.update_date IS NULL --Added Condition
Here, I am assuming is_updated=0
means not updated and update_date
is nullable & set only when value is edited.
If above assumption is not good for you, you can change where condition accordingly.