MERGE INTO table_Online USING table_ExcelON table_Online.[key_o] = table_Excel.[key_e]WHEN MATCHEDTHEN UPDATE SET table_Online.[商户,门店名称,门店所属区域,门店地址,商户分类] = table_Excel.[商户,门店名称,门店所属区域,门店地址,商户分类] --更新WHEN NOT MATCHED THEN INSERT VALUES (table_Excel.[
--sql多表更新update PMS_Financial_Gathering set ShouldMoney=PMS_Contract_RentScheme.Rentfrom PMS_Financial_Gatheringinner join PMS_Contract_RentScheme on PMS_Financial_Gathering.RentSchemeCode=PMS_Contract_RentScheme.RentSchemeCode
1. 写法轻松,更新效率高: update table1 set field1=table2.field1, field2=table2.field2 from table2 where table1.id=table2.id 2. 常规方式,种写法相当于一个 Left join, 以外面的where为更新条数,如果不加where就是所有记录 update table1 set field1=(select top 1 field1 from table2 where table2.id=tab