update vs4tproduct2 set tpd2hasbom=(select count(tpmttpdtcode) from vs4tproductmat where tpmttpdtcode=tpd2tpdtcode)
+(select count(tspdtpdtcode) from vs4tproductmethod where tspdtpdtcode=tpd2tpdtcode)
update vs4tproduct2 set tpd2hasbom=1 where tpd2hasbom<>0