SQL 多表批量插入 更新_SQLSQL 多表批量插入 更新_SQL_02

UPDATE CM_Contract
SET F1=b.HtClass,F2=b.IsFyControl
FROM CM_Contract a INNER JOIN dbo.dc_cb_Contract_temp2019 b ON a.contractId=b.contractId


insert into CM_Contract
([ContractId],[ProjectId],[SupplierId],[ContractNumber],[ContractName],[ContractAmount],
[ContractStatus],[SeqNo],[Isdeleted],[CreateUserName],[CreateDate],[ModifyDate],[ContractUrl],
[F1],[F2])
(select [ContractId],[ProjectId],[SupplierId],[ContractNumber],[ContractName],[ContractAmount],
[ContractStatus],0,0,'明源',SignDate,SignDate,contractEditUrl,
HtClass,[IsFyControl]
from dc_cb_Contract_temp2019
where [ContractId] not in(select [ContractId] from CM_Contract) and [ProjectId] not like '%;%'
)

View Code


UPDATE SM_SupplierAccount

SET SupplierAccount=b.LicenceNo

FROM SM_SupplierAccount a INNER JOIN dbo.SM_supplier b ON a.SupplierId=b.SupplierId

where (a.SupplierAccount is null or a.SupplierAccount='' ) and b.LicenceNo is not null and b.LicenceNo !=''

​​